I am creating a small plugin to update a database table. The updater scriipt works properly when included in a Wordpress page or post template, but not when included in a script run by a form action from the plugin. (action="script.php")
Non Object Error in Wordpress
4
I am creating a small plugin to update a database table.
The updater scriipt works properly when included in a Wordpress page or post template, but not when included in a script run by a form action from the plugin. (action="script.php")
This is the error: where the error message references the fourth line of the code below where I am setting $result to the sql.
From what I can find, which corresponds with what I suspected, the Wordpress framework, or whatever it is called, is not included in this small script, even though it is called by a plugin.
What is the correct way of getting the Wordpress functions, and framework, etc., loaded in this small script?
Many thanks for your consideration and help!
Kirk
The updater scriipt works properly when included in a Wordpress page or post template, but not when included in a script run by a form action from the plugin. (action="script.php")
This is the error: where the error message references the fourth line of the code below where I am setting $result to the sql.
Code:
global $wpdb; $table_name = $wpdb->prefix . "my_table_name"; $sql = "TRUNCATE " . $table_name; $result = $wpdb->query($wpdb->prepare($sql));
What is the correct way of getting the Wordpress functions, and framework, etc., loaded in this small script?
Many thanks for your consideration and help!
Kirk
- Michael71
- [ 1 ] Thanks
- [1] reply
- Kirk Ward
- Kirk Ward
Next Topics on Trending Feed
-
4