I am trying to create a plug-in which uses a table that I added into my database. The plugin creates a widget which has a multiple choice question form. When the form submits, it goes to my submit.php file which is located in the same plugin folder.
On the submit.php file, I am trying to run a query to update some values in the table I built by using this:
$update = $wpdb->update( my_table, array ( guesses=>$numGuesses), array (id=>$id));
Although I have the “global $wpdb” defined, I still receive “Fatal error: Call to a member function get_results() on a non-object”. The widget successfully uses the $wpdb as it queries the same table to pull the data for the questions (uses $wpdb->get_results()). I don’t understand what I am doing wrong to make this not work, for I have looked over both files and nothing appears to be different.
Does anybody have any thoughts on what it could be?
- The topic ‘Error using $wpdb in a plugin’ is closed to new replies.