sonal Posted June 26, 2012 Share Posted June 26, 2012 I have following update statement in one of the script, and it is not working. I tried to debug as much as I can without success. What can be the problem? $rating = 4; $q = "UPDATE user_book_trn SET book_rating = ? WHERE user_id = 1 AND member_id=24 AND book_id=120"; $r = mysqli_prepare($dbc, $q) or trigger_error("Query: $q\n<br />" . mysqli_error($dbc)); mysqli_bind_param($r, 'i', $br); $br = (int) $rating; //echo "\n rating : " . $br; mysqli_stmt_execute($r); if(mysqli_stmt_affected_rows($r)==1) { echo "Thanks for submitting your rating for the book. We appreciate it!"; } else { echo "error"; echo '<p>' . mysqli_stmt_error($r) . '</p>'; } The query runs OK in phpmyAdmin with the given values and also for other values in tables. But this script always prints "error" message, but never shows any mysqli_stmt_error. Link to comment Share on other sites More sharing options...
margaux Posted June 26, 2012 Share Posted June 26, 2012 Since $rating is defined, your update statement is not changing any values therefore mysql will return zero rows but has not encountered an error. Try changing $rating. Link to comment Share on other sites More sharing options...
Recommended Posts