php - mysqli_query() returns "Table doesn't exist" for known table - Permissions issue? -
here's code:
$dsn = "dbinstancename.c5twsfnt9pph.us-east-1.rds.amazonaws.com"; $port = "3306"; $db = "mysql"; $username = "username"; $password = "password"; $sourcetable = "test"; //initialize connection $link = mysqli_connect($dsn, $username, $password, $db, $port); if ($link->connect_error){ echo "connection failed"; } if(mysqli_connect_error()){ echo 'mysql error: ' . mysqli_connect_error(); } if(mysqli_select_db($link, $db)){ echo 'connected successfully'; } //set initial source id import $sourceid = "1"; // first source url , name $query = "select * $sourcetable id = $sourceid;"; //echo $query; $result = mysqli_query($link, $query); if($result === false) { echo "query failed"; echo mysqli_error($link); }else{ while ($row = mysqli_fetch_assoc($result)) { echo $row['name']; echo $row['url']; } } //echo "finished"; ?>
the issue table test exist , contains data. test table in database mysql.
if change value of database given error cannot connect (even other known databases beside mysql).
when program runs output "connected successfullyquery failedtable 'mysql.test' doesn't exist"
any hugely appreciated. aws rds instance running mariadb, , php running ec2 micro instance.
edit: here mysql string prove table exists:
mariadb [(none)]> use mysql reading table information completion of table , column names can turn off feature quicker startup -a database changed mariadb [mysql]> show tables; +---------------------------+ | tables_in_mysql | +---------------------------+ | column_stats | | columns_priv | | db | | event | | func | | general_log | | gtid_slave_pos | | help_category | | help_keyword | | help_relation | | help_topic | | host | | index_stats | | innodb_index_stats | | innodb_table_stats | | plugin | | proc | | procs_priv | | proxies_priv | | roles_mapping | | servers | | slow_log | | table_stats | | tables_priv | | test | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 31 rows in set (0.00 sec) mariadb [mysql]> select * test; +----+--------+------------+ | id | name | url | +----+--------+------------+ | 1 | banana | banana.com | +----+--------+------------+ 1 row in set (0.00 sec)
Comments
Post a Comment