Title: $wpdb-&gt;insert issue
Last modified: August 19, 2016

---

# $wpdb->insert issue

 *  Resolved [gusqc](https://wordpress.org/support/users/gusqc/)
 * (@gusqc)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wpdb-gtinsert-issue/)
 * Hi,
 * First time writing a plugin for WordPress. I am trying to insert data into wp_wptest,
   a table I created in the database. The below code inserts 12 rows in the database
   instead of one. The string “INSERT” only prints once in the page source. I only
   want to insert one row in the db. Here is the code:
 *     ```
       echo "INSERT" . "<br />";
   
       $this->m_pathlogo = "AAAAA.gif";
       $this->m_customerid = 1;
   
       $dbfields["customerid"] = $this->m_customerid;
       $dbfields["pathlogo"] = $this->m_pathlogo;
       $dbfields["date"] = "now()";
   
       $wpdb->insert( 'wp_wptest', $dbfields);
       ```
   
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wpdb-gtinsert-issue/#post-1459509)
 * You code would look to be correct…so just a few things to try:
 * Put this before your insert statement to see if it tells you anything:
 *     ```
       echo "<pre>"; print_r($dbfields); echo "</pre>";
       ```
   
 * Change the insert statement to
 *     ```
       $result = $wpdb->insert( 'wp_wptest', $dbfields);
       ```
   
 * Also, this after the insert to see if the return shows anything
 *     ```
       echo "<pre>"; print_r($result); echo "</pre>";
       ```
   
 *  Thread Starter [gusqc](https://wordpress.org/support/users/gusqc/)
 * (@gusqc)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wpdb-gtinsert-issue/#post-1459525)
 * Thanks alot, it fixed the issue!
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wpdb-gtinsert-issue/#post-1459529)
 * SO I guess this fixed it?
 *     ```
       $result = $wpdb->insert( 'wp_wptest', $dbfields);
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘$wpdb->insert issue’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 3 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/wpdb-gtinsert-issue/#post-1459529)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
