WordPress.org

Ready to get started?Download WordPress

Forums

Plugin won't insert data into new table (3 posts)

  1. poodlerat
    Member
    Posted 6 years ago #

    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!

  2. WebTechGlobal
    Member
    Posted 5 years ago #

    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?!

  3. adamh
    Member
    Posted 5 years ago #

    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')");

Topic Closed

This topic has been closed to new replies.

About this Topic