Title: $wpdb insert problem &#8211; not inserting string
Last modified: August 20, 2016

---

# $wpdb insert problem – not inserting string

 *  [Chris](https://wordpress.org/support/users/chips/)
 * (@chips)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/wpdb-insert-problem-not-inserting-string/)
 * I am trying to insert a new record into a table, and for the most part it’s working
   except for one string. Here’s my insert statement;
 * `$wpdb->insert($wpdb->uam_accessgroup_to_object, array('object_id' => $userID,'
   object_type' => 'user', 'group_id' => $entry['7']), array('%s', '%d'));`
 * It’s creating a new record and inserting the correct values into ‘object_id’ 
   and ‘group_id’, however ‘object_type’ which should be ‘user’ is saved in the 
   db as ‘0’. The field type is varchar(255).
 * Is there something wrong with my insert statement?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Chris](https://wordpress.org/support/users/chips/)
 * (@chips)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/wpdb-insert-problem-not-inserting-string/#post-3058534)
 * Very strange, I moved the second field to be first in the array and it works.
   Code now reads;
 * `$wpdb->insert($wpdb->uam_accessgroup_to_object, array('object_type' => 'user','
   object_id' => $userID, 'group_id' => $entry['7']), array('%s', '%d'));`

Viewing 1 replies (of 1 total)

The topic ‘$wpdb insert problem – not inserting string’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [Chris](https://wordpress.org/support/users/chips/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/wpdb-insert-problem-not-inserting-string/#post-3058534)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
