What I'm trying to do is: (programmatically)
Refresh status, where id is something, if not a single line where it is updated gives an error: we cannot find the record with the identifier something, otherwise we report the success of the message.
Here I use mysql_affected_rows () to find out if the row has been updated or not, but it always returns 1, so the user receives a success message, although the updated row is not updated.
Can someone tell me what it could be?
Here is the code:
function update_sql($sql) {
$this->last_query = $sql;
$r = mysql_query($sql);
if (!$r) {
$this->last_error = mysql_error();
return false;
}
$rows = mysql_affected_rows();
if ($rows == 0) return true;
else return $rows; }
This code returns 1.
source
share