Reputation: 964
I have a custom wordpress table(my_table). And i am inserting,updating all that good stuff to it. When i try to use
$wpdb->get_results("SELECT * FROM $wpdb->my_table",ARRAY_A);
or
$wpdb->get_results("SELECT * FROM my_table",ARRAY_A);
I get this error
WordPress database error: [Table 'mydatabase.my_table' doesn't exist]
SELECT * FROM my_table
I have tried to add my_table to wp-db.php as well but i still receive this error.
Is their a config option of i need to change or somewhere else where i need to add my table name? I cannot find it for some reason.
full error
WordPress database error Table 'mydatabase.mytable' doesn't exist for query SELECT * FROM mytable made by do_action, call_user_func_array, promos
Upvotes: 0
Views: 1019
Reputation: 2269
Ok tiggles, here is what I would do in your situation if you are still stuck. Create a new table, but this time, by executing a SQL command from WordPress, using something like :
$wpdb->query('CREATE TABLE mynewtable (First_Name char(50), Last_Name char(50), ... etc.)');
Immediately check that you can query it. If so, then go to your databse and dump all data from mytable
into this newly created table. Use this one instead.
If it was a user permission because the user that created the previous table was not the same as the one granted access to as WordPress, then you will be safe.
Upvotes: 1
Reputation: 2269
If your table my_table
is, indeed, in the mydatabase
database and if mydatabase
is, indeed, WordPress' database, there is no reason why it should not work. If mydatabase
is not WordPress database or if my_table
is in another database, then it is normal that it does not work.
Upvotes: 0