Title: Plugin won&#8217;t insert data into new table
Last modified: August 19, 2016

---

# Plugin won’t insert data into new table

 *  [poodlerat](https://wordpress.org/support/users/poodlerat/)
 * (@poodlerat)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-insert-data-into-new-table/)
 * 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)

 *  [WebTechGlobal](https://wordpress.org/support/users/webtechglobal/)
 * (@webtechglobal)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-insert-data-into-new-table/#post-824741)
 * 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?!
 *  [adamh](https://wordpress.org/support/users/adamh/)
 * (@adamh)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-insert-data-into-new-table/#post-824742)
 * 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.

## Tags

 * [$wpdb->query](https://wordpress.org/support/topic-tag/wpdb-query/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [new table](https://wordpress.org/support/topic-tag/new-table/)

 * 2 replies
 * 3 participants
 * Last reply from: [adamh](https://wordpress.org/support/users/adamh/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-wont-insert-data-into-new-table/#post-824742)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
