If UPDATE
doesn't match anything to update it will simply return. This is not an error. To find out whether it's updated anything use mysql_affected_rows()
.
Note: mysql_*()
doesn't support the OOP form, so you should use mysql_affected_rows()
, which should work for your second case above.
This will give you:
if (strcasecmp($actionIn, 'update') == 0) {
$query = "UPDATE $usertable SET id = '$id', fname = '$fname', lname = '$lname' WHERE id = '$id'";
$result = mysql_query($query) or die(mysql_error());
if (mysql_affected_rows() !== 0) {
$arr['updated'] = 'true';
}
Side note: mysql_*()
is deprecated and will be removed. You should use mysqli
or PDO
for new code.