Re: Making a true statement false.
| From: | ed at home dot homes2see dot com | Date: | Fri, 07 Mar 2003 16:38:00 +0000 |
| Subject: | Re: Making a true statement false. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138657@lists.php.net to get a copy of this message | ||
Thanks for all the help. I was just placing the ! in the wrong place.
Thanks again,
Ed
On Fri, 7 Mar 2003, Greg Beaver wrote:
>
>
> Mincu Alexandru wrote:
> > On Fri, 2003-03-07 at 18:16, ed@home.homes2see.com wrote:
> >
> >>Whenever I query a database with php I've always used the following code
> >>as a result.
> >>
> >
> > this way:
> >
> > if (!$row = mysql_fetch_array($result)) {
> > do something }
> > else {
> > do seomthing else }
>
> It is simpler to do this:
>
> if ($row = mysql_fetch_array($result)) {
> do something else
> } else {
> do something
> }
>
> You would be well advised to use this syntax:
>
> if (!($row = mysql_fetch_array($result)))
>
> to ensure operator precedence is clear. (the equals followed by not)
>
> Regards,
> Greg
> --
> phpDocumentor
> http://www.phpdoc.org
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>