Results 1 to 6 of 6
Jan 3, 2013, 22:34 #1
- Join Date
- Aug 2010
- 2 Post(s)
- 0 Thread(s)
Prepared Statement only updating One Record
I have a Prepared Statement that is supposed to take a list of Message ID's and update several records all at once using a single UPDATE query.
Here is an example of what the actual SQL might look like...
UPDATE private_msg_recipient SET read_on=NULL, updated_on=NOW() WHERE member_id_to=19 AND message_id IN (52, 51, 49, 39, 38, 10, 8, 6, 5, 2, 1)
Towards the top of my script I have this code...
echo '$messagesToUpdate = ' . $messagesToUpdate;
$messagesToUpdate = 52, 49, 38
The problem is that when I run my script, my Prepared Statement is only updating the *first* value in $messagesToUpdate...
Here is a snippet of my code...
// Build query.
$q1 = "UPDATE private_msg_recipient
SET read_on = NULL,
updated_on = NOW()
WHERE member_id_to = ?
AND message_id IN (?)";
// Prepare statement.
$stmt1 = mysqli_prepare($dbc, $q1);
// Bind variables to query.
mysqli_stmt_bind_param($stmt1, 'is', $sessMemberID, $messagesToUpdate);
// Execute query.
// Verify Update.
// Update Succeeded.
// Update Failed.
What am I doing wrong here??
(Originally I had 'ii' in my mysqli_stmt_bind_param statement, and I thought that was the issue, but even with 'is' things still aren't working?!)