Re: Num rows error

From: Date: Tue, 10 Oct 2000 23:32:53 +0000
Subject: Re: Num rows error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-19443@lists.php.net to get a copy of this message
At 06:29 PM 10/10/00 , Dallas Kropka wrote:
this is the code. $check = "SELECT * FROM list WHERE email = '$email'"; $query = mysql_query($check); $num_rows = mysql_num_rows($query); if ($num_rows) $email_exitst=1; im getting an error that says this... Supplied argument is not a valid MySQL result resource
And just as an aside, if you aren't doing anything other than getting a count of records with that email address, it is more efficient to use a query like $check = "SELECT COUNT(*) AS n FROM list WHERE email = '$email'"; $query = mysql_query($check); $x = mysql_fetch_array($query); $num_rows = $x['n']; MySQL does a very good job of optimizing SELECT COUNT(*) queries. -steve +------------------------------------------------------------------------+
| Steve Edberg                           University of California, Davis |
| sbedberg@ucdavis.edu                                     (530)754-9127 |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

« previous php.general (#19443) next »