Would appreciate the advise of SO's php/MySQL experts! I am stumped by the following seemingly simple piece of php code.
$queryDel = 'UPDATE `cocoon_result` SET `image` = NULL WHERE `id` = "B" AND `post_id` = 183';
$resultDel = mysqli_query($mysqli, $queryDel);
if (!$resultDel)
$msg .= 'Errormessage: ' . mysqli_error($mysqli) . '<br />';
else if (mysqli_affected_rows($mysqli) == 0)
$msg .= 'Errormessage: ' . mysqli_error($mysqli) . '<br />';
else
$msg .= mysqli_affected_rows($mysqli) 'row(s) affected. What the ??';
The statement succeeds and says that 1 row is affected. However image is still the old value. When I entered the same sql statement via phpMyAdmin, the update works. I have tried updating image to '' and '123' and the error persists so it's not just when image = NULL.
The PRIMARY KEY for table cocoon_result is id and post_id.
Edit: I've transplanted this snippet of code into a new file and it works... it just doesn't work together with the other lines of code in the original file. I've incrementally added back the other parts of the code to this new file and it still works but it's going to be quite crazy for me to add lines of code bit by bit till the original file is reproduced... Plus I'm darn curious as to the reason for this strange behaviour. Anyone?