Hello. I have written custom Plugin for WordPress 2.9.2.
I have created unique table in mySQL scheme called "leaders".
I am able to read from the table with a widget I wrote and the following code:
global $wpdb; $rows = $wpdb->get_results('SELECT leader_id, leader_title FROM leaders WHERE project_abbrev = '.$project_abbrev.' ORDER BY leader_order');
I am writing custom plugin that has Admin Panel with forms to insert the data into the table (to then be read by the widget).
For the life of me, I can't figure out why the INSERT statement in my plugin is NOT WORKING. Everything executes with NO PHP errors/warning, but no records show up in the mySQL table 'leaders'.
Here is my code for INSERTing to table 'leaders' in Plugin:
global $wpdb; $project_abbrev = $_POST[ 'project_abbrev' ]; $leader_title = $_POST[ 'leader_title' ]; $leader_price = $_POST[ 'leader_price' ]; $leader_desc = $_POST[ 'leader_desc' ]; $leader_order = $_POST[ 'leader_order' ]; $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->leaders ( project_abbbrev, leader_title, leader_price, leader_desc, leader_order ) VALUES ( %s, %s, %s, %s, %d )", 'Test Abbrev','Test Title','$39,900','THIS IS DESC',2) );
I have also tried the following INSERT statements... all using $wpdb for the INSERTs:
$wpdb->insert( 'leaders', array( 'project_abbbrev' => $project_abbrev, 'leader_title' => $leader_title, 'leader_price' => $leader_price, 'leader_desc' => $leader_desc, 'leader_order' => $leader_order ), array( '%s', '%s', '%s', '%s', '%d' ) ); $wpdb->query( $wpdb->prepare( " INSERT INTO $wpdb->leaders ( project_abbbrev, leader_title, leader_price, leader_desc, order ) VALUES ( %s, %s, %s, %s, %d )", array('Test Abbrev','Test Title','$39,900','THIS IS DESC',2) ) );
Anyone got some ideas/suggestions. Thanks in advance!
Been searching these forums and elsewhere without finding anything.