Re: mysql_num_rows() <-- works but sometimes gives error?
| From: | Brian Feliciano | Date: | Wed, 23 Jan 2002 05:17:09 +0000 |
| Subject: | Re: mysql_num_rows() <-- works but sometimes gives error? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81639@lists.php.net to get a copy of this message | ||
pschwar@jhmi.edu writes:
>When I use the function "mysql_num_rows()" it will work just fine except
>that SOMETIMES I get this error message...
>
>Warning: Supplied argument is not a valid MySQL result resource in
>/blahblah/patient/afterpassword.php on line 67
>
>Here is the code...
>
>65 $query = "UPDATE users set password='$newpassword' WHERE username =
>'$user'";
> 66 $result = mysql_query($query);
>67 $num_results = mysql_num_rows($result);
>
this is just a guess, UPDATE queries does not return a result set and your
mysql_num_rows counts all the rows in your result set.
You should use mysql_affected_rows(). to check rows affected.
>what am I doing wrong here??
>
>Thanks!