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

---

# wpdb->insert problem

 *  Resolved [billc108](https://wordpress.org/support/users/billc108/)
 * (@billc108)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/wpdb-insert-problem/)
 * I’m having some trouble with wpdb->insert. From everything I’ve read, the insert
   below should be formatted correctly. The database has a table named Directory
   with four columns as named.
 * `$insertresult = $wpdb->insert('Directory', array( 'dir_id' => '4', 'U_ID' =>'
   2227', 'contactname' => 'contact', 'contactnamedisplay'=>'1'));`
 * This is my first time working with $wpdb… I can easily do the same with a regular
   database query, but I’m trying to play by WP’s rules. Any idea where I’m messing
   up?
 * Thanks.

Viewing 1 replies (of 1 total)

 *  Thread Starter [billc108](https://wordpress.org/support/users/billc108/)
 * (@billc108)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/wpdb-insert-problem/#post-1844208)
 * Solved. I didn’t have
    `global $wpdb;` where it would affect the particular if
   statement which was showing problems.

Viewing 1 replies (of 1 total)

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

 * 1 reply
 * 1 participant
 * Last reply from: [billc108](https://wordpress.org/support/users/billc108/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/wpdb-insert-problem/#post-1844208)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
