intrigue Posted October 26, 2006 Share Posted October 26, 2006 Please can anyone tell me why i get this error with the following script[b]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\autoFinder\admin\functions\authenticate.php on line 62[/b][pre]if (isset($id)) { echo("hey"); $search = "SELECT * FROM ct_clients WHERE accountHash = '".$id."'"; $result = mysql_query($search) or die(mysql_error()); if ($row = mysql_fetch_array($result)) { $search2 = "UPDATE ct_clients SET password = '".md5($password)."' WHERE accountHash = '".$id."' LIMIT 1"; $result2 = mysql_query($search2) or die(mysql_error()); [b]// LINE62[/b] if ($row2 = mysql_fetch_array($result2)) { echo("Password updated<br />"); echo("Email sent.<br />"); } } }[/pre] Link to comment https://forums.phpfreaks.com/topic/25178-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result/ Share on other sites More sharing options...
akitchin Posted October 26, 2006 Share Posted October 26, 2006 an UPDATE query does not return any rows, therefore you cannot run mysql_fetch_array() on its resource ID. if you want to find out how many rows were affected in the last update, delete, etc. use mysql_affected_rows(). Link to comment https://forums.phpfreaks.com/topic/25178-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result/#findComment-114756 Share on other sites More sharing options...
intrigue Posted October 26, 2006 Author Share Posted October 26, 2006 Thanks i was able to test if affected rows = 1 or 0 and display my error message. ;Dmatt Link to comment https://forums.phpfreaks.com/topic/25178-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result/#findComment-114775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.