Re: Re: Passing by conditional IF statement...why?
| From: | Daniel Guerrier | Date: | Tue, 23 Mar 2004 01:49:07 +0000 |
| Subject: | Re: Re: Passing by conditional IF statement...why? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181217@lists.php.net to get a copy of this message | ||
if(mysql_num_rows($res))
returns count of rows returned.
if it 0 is false so it shouldn't execute the
conditional code
--- Ligaya Turmelle <lig@mgpt.com> wrote:
> I think it is because the query ran successfully and
> returns an empty set.
> So the pointer is still good.
>
> Respectfully,
> Ligaya Turmelle
>
>
> "Ryan A" <ryan@coinpass.com> wrote in message
>
news:000301c4106e$f4ddf390$f081aa51@l2zcaxu7emppqh...
> > Hi,
> > I have this simple code in my php script:
> >
> > * * * * *
> > $res = mysql_query("SELECT product_id, now()-1
> FROM ".$tc."_prods where
> > cno=$cno AND product_id='$product_id' LIMIT 1");
> >
> > if($res)
> > {
> > $r = mysql_fetch_row($res);
> > $product_id2 = $r[0];
> > $th_pres= $r[1];
> > echo "debug echo";
> > }else {echo "No results, sorry";}
> > * * * * *
> >
> > its working great when the data actually exists
> but when there are no
> > matches it still executes the "if($res)" part
> instead of
> > displaying "No results, sorry".
> > Why is that? or am I using the syntax wrong?
> >
> > Thanks,
> > -Ryan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html