Re: mysql_query

From: Date: Tue, 09 Jan 2001 17:34:38 +0000
Subject: Re: mysql_query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33500@lists.php.net to get a copy of this message
> when I do a mysql_query on php, like > > $result=mysql_query("select * from counter where date='2001-01-06'"); > > In case of there is no date='2001-01-06', what should be the contents of > $result? > > How can I know that was no data of '2001-01-06' in database? > _____________________ > > you answer me like that: > > $hoje=date("'Y-m-d'"); > if (mysql_query("select unique,total from counter where data=$hoje")){ > echo "true"; > }else{ > echo "false"; > } This answer is incorrect. mysql_query() will return true if the query sent is valid and a result set is returned. A result set with 0 elements is still a valid result set. You want something like this: $result=mysql_query(...) if(mysql_numrows($result) > 0) { ... rows found ... } else { ... no rows found ... } -Rasmus

« previous php.general (#33500) next »