Reputation: 1
I have an update query which is not working for me. I am able to make selects quite happily on the same page but I cannot get an update statement to work. The table is not a part of wordpress so Im wondering if that could be it or if I have just got something wrong.
$query = "UPDATE login_count SET `count` = '100' WHERE `user_id` = $userID ";
$insrt = $wpdb->query($query);
Upvotes: 0
Views: 760
Reputation: 1040
$insrt = $wpdb->update(
'login_count', //table_name
array(
'count' => '100', // string
),
array( 'user_id' => $user_id ), //Where Condition
array(
'%d', // value1
),
array( '%d' )
);
Upvotes: 2
Reputation: 700
Try this,
$insrt = $wpdb->update(
'login_count', //table_name
array('count'=>'100'),//data
array('user_id'=>$userID),//where
array('%s'),//data format
array('%s')
);
Upvotes: 3
Reputation: 727
Try this ..user_id = {$userID} ";
Edit
See: Use a $variable inside a SQL string?
Upvotes: 0