• I’ve created a new table to hold form data, but I can’t get my plugin to insert any new records. Here’s the code I’m using:

    $wpdb->query("INSERT INTO wp_reg (ID, slname, sfname, plname, pfname, email, phone, cellphone) VALUES (NULL, $slname, $sfname, $plname, $pfname, $email, $phone, $cellphone)");

    Can someone who knows more about PHP, MySQL, and the $wpdb class help me figure out how to get this to work? (And if there’s nothing wrong with the code, might there be something wrong with how the database is set up that would prevent new records being inserted?)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theres a lot of people with this problem around the net and I can get other query working but not one similiar too yours.

    There must be something missing or misleading about the documentation?!

    You need to wrap your values in speech marks:

    $wpdb->query("INSERT INTO wp_reg (ID, slname, sfname, plname, pfname, email, phone, cellphone) VALUES (NULL, '$slname', '$sfname', '$plname', '$pfname', '$email', '$phone', '$cellphone')");

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin won’t insert data into new table’ is closed to new replies.