Title: DB insertion
Last modified: August 19, 2016

---

# DB insertion

 *  Resolved [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/)
 * i am trying to insert data into my own table in the DB
 * this is the line of code i am using
 * `$wpdb->insert($wpdb->something, $data);`
 * ‘something’ is the table name in the DB and the $data array has the correct field
   names in the correct order with the correct value types
 * however the records are not being inserted into the DB.
 * do i need to add the table name into wordpress’s php files somewhere or is the
   table list dynamic?
 * Any help would be greatly apprecaited
 * Ilan

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350023)
 * Might want to check the insert and prepare discussion in [wpdb](http://codex.wordpress.org/wpdb).
 *  [magickman5](https://wordpress.org/support/users/magickman5/)
 * (@magickman5)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350031)
 * hi iperez_genius,
    check whether you have added any prefix to the wordpress tables…
   like $prefix=’wp_’; so the table name is wp_posts
 *  Thread Starter [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350095)
 * magickman5 you were partly correct
 * even though i updated the table name to be
 * wp_something the table name wasn’t in the query so instead of using
 * `$wpdb->insert($wpdb->something, $data);`
    i used `$wpdb->insert('wp_something',
   $data);`
 * that fixed the problem…i have a new problem though. Because i have added something
   to the comment.php and wp_new_comment.php when i try to delete a comment i receive
   an error…i am looking into that now. here is the error
 * `Fatal error: Call to undefined function wp_trash_comment() in /home/sydneyme/
   public_html/dir/wp-admin/admin-ajax.php on line 217`
 *  [magickman5](https://wordpress.org/support/users/magickman5/)
 * (@magickman5)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350096)
 * hi iperez_genius,
 * thats what i actually meant. The syntax for insert is
 * $wpdb->insert( ‘table’, array( ‘column1’ => ‘value1’, ‘column2’ => 123 ), array(‘%
   s’, ‘%d’ ) )
 * so as i told you “**check whether you have added any prefix to the wordpress 
   tables… like
    $prefix=’wp_’;
   ” at the time of installation.
 * but anyways we got it correct…cheers and i will look into the next issue also.
 *  Thread Starter [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350098)
 * so it turns out that the trash function some how got deleted from the comment.
   php file…
 * i have no idea why…but i added the functions back in and all is well so…
 * everything is resolved!
 * thanks for all the help.
 * Ilan

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

The topic ‘DB insertion’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/db-insertion/#post-1350098)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
