Jump to content


Photo

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result


  • Please log in to reply
2 replies to this topic

#1 intrigue

intrigue
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 26 October 2006 - 01:57 PM

Please can anyone tell me why i get this error with the following script
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

[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()); // LINE62
if ($row2 = mysql_fetch_array($result2))
{
echo("Password updated<br />");
echo("Email sent.<br />");
}
}
}
[/pre]

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 26 October 2006 - 02:16 PM

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().

#3 intrigue

intrigue
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 26 October 2006 - 02:48 PM

Thanks i was able to test if affected rows = 1 or 0 and display my error message.
;D
matt




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users