Re: mysql_query
| From: | Augusto Cesar Castoldi | Date: | Tue, 09 Jan 2001 17:55:24 +0000 |
| Subject: | Re: mysql_query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33507@lists.php.net to get a copy of this message | ||
I think that's almost working now.
It appears on browser:
____________
Warning: Supplied argument is not a valid MySQL result resource in
/home/cco/castoldi/public_html/teste/index.php on line 10
No Rows founded
_____________
The php code is:
________
if (mysql_numrows($result) > 0) {
echo "Rows founded";
} else {
echo "No Rows founded";
}
_______
What is this message?
thanks,
Augusto Cesar Castoldi
On Tue, 9 Jan 2001, Rasmus Lerdorf wrote:
> > 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>