| | #1 | |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
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:
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 | |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | ||
| |
| | #2 |
| ResponsiveDesignTest.Net Registered Member Join Date: 2011 Location: Rostock, Germany
Posts: 829
Thanks: 106
Thanked 225 Times in 194 Posts
|
require( './wp-load.php' ); (edit the path)
|
|
HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing --- Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu | |
| |
| The Following User Says Thank You to Michael71 For This Useful Post: |
| | #3 |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
Awesome! The script is at Code: /var/www/html/wp-content/plugins/my-plugin/my-file-name.php Code: /var/www/html/wp-load.php Next step is to get it to use a relative path. I'll keep working on that! Many, many thanks! |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | |
| |
| | #4 |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
P.S. - If the script allowed me to give more thanks, I'd have added three hundred and seventy-four just to start, with more to come later!
|
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | |
| |
|
| Bookmarks |
| Tags |
| error, object, wordpress |
| |