I'm trying to use mysql_affected_rows to determine if an update was done or not.
Here's a query string:
UPDATE staff SET first_name='first', email='', last_name='last', phone='', bio='', sec_lvl='MSTR', active='Y', dept='MSTR' WHERE id='2'
My problem is that if I use if($result), an update may not have been made, but the that condition is considered passing.
If I use mysql_affected_rows, then it says it has failed everytime. The result of affected rows is always 0, but the update may still have been done.
id can equal a number or id can equal nothing, and it will always 'say' it failed in affected_rows, or it will always 'say' it passed if I merely use if($result).
Also, here's the pre version of the query string:
$query_string="UPDATE staff SET first_name='$first_name', email='$email', last_name='$last_name', phone='$phone', bio='$bio', sec_lvl='$sec_lvl', active='$active', dept='$dept' WHERE id='$id' ";
$result=mysql_query("$query_string")or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query_string . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
Anyone have anything to rectify my stupidity?
Here's a query string:
UPDATE staff SET first_name='first', email='', last_name='last', phone='', bio='', sec_lvl='MSTR', active='Y', dept='MSTR' WHERE id='2'
My problem is that if I use if($result), an update may not have been made, but the that condition is considered passing.
If I use mysql_affected_rows, then it says it has failed everytime. The result of affected rows is always 0, but the update may still have been done.
id can equal a number or id can equal nothing, and it will always 'say' it failed in affected_rows, or it will always 'say' it passed if I merely use if($result).
Also, here's the pre version of the query string:
$query_string="UPDATE staff SET first_name='$first_name', email='$email', last_name='$last_name', phone='$phone', bio='$bio', sec_lvl='$sec_lvl', active='$active', dept='$dept' WHERE id='$id' ";
$result=mysql_query("$query_string")or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query_string . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
Anyone have anything to rectify my stupidity?