Title: Data Not Inserted into Database upon submitting form
Last modified: August 19, 2016

---

# Data Not Inserted into Database upon submitting form

 *  [Travis Tubbs](https://wordpress.org/support/users/travistubbs/)
 * (@travistubbs)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/data-not-inserted-into-database-upon-submitting-form/)
 * Well, I figured I’d give things a shot and attempt to create my first WordPress
   plugin. I’ve been successful in creating the Admin menus, creating a new Database
   table (when it doesn’t exist), and reading data from the Database.
 * I am now attempting to add data to the database, but it seems no matter how many
   times I submit the data, nothing is added to the database.
 * Here is the code that I’m using:
 *     ```
       $sql = "INSERT INTO " . $wpdb->prefix . "table_name
                         (table_row_name, table_row_2, table_row_3) VALUES (
                         '" . $wpdb->escape($_POST['table_row_name']) . "',
                         '" . $wpdb->escape($_POST['table_row_2']) . "',
                         '" . $wpdb->escape($_POST['table_row_3']) . "'
                         )";
               $wpdb->query($sql);
       ```
   
 * As stated in the WordPress documentation about working with databases, I have
   included the following lines of code beforehand:
 *     ```
       include_once(ABSPATH . 'wp-config.php');
       include_once(ABSPATH . 'wp-includes/wp-db.php');
       ```
   
 * I am definitely missing something here, but I am lost as to what. I’ve ensured
   that the SQL statement is complete with the values that are passed from the form(
   echoed the $sql variable on the “results” page). I don’t get any errors, but 
   am completely lost as to what is going on. Any pointers?

Viewing 1 replies (of 1 total)

 *  [mostfamiliar](https://wordpress.org/support/users/mostfamiliar/)
 * (@mostfamiliar)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/data-not-inserted-into-database-upon-submitting-form/#post-688918)
 * Did you ever find a solution? I’m experiencing a similar problem.

Viewing 1 replies (of 1 total)

The topic ‘Data Not Inserted into Database upon submitting form’ is closed to new
replies.

## Tags

 * [$wpdb->query](https://wordpress.org/support/topic-tag/wpdb-query/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [insert into](https://wordpress.org/support/topic-tag/insert-into/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * 1 reply
 * 2 participants
 * Last reply from: [mostfamiliar](https://wordpress.org/support/users/mostfamiliar/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/data-not-inserted-into-database-upon-submitting-form/#post-688918)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
