Re: [PHP] What's wrong with this IF statement?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Robert Sossomon" <robert@xxxxxxxxxxxx>

>   if ($cat_id != "53" || $cat_id != "54" || $cat_id != "55" || $cat_id
> != "117" || $cat_id != "118" || $cat_id != "74")

Okay, if $cat_id is 53, this will work out to:

if(FALSE || TRUE || TRUE || TRUE || TRUE || TRUE)

which results in TRUE overall. 

You want && instead of ||

if ($cat_id != "53" && $cat_id != "54" && $cat_id != "55" && $cat_id
!= "117" && $cat_id != "118" && $cat_id != "74")

which results in

if(FALSE && TRUE && TRUE && TRUE && TRUE && TRUE)

which results in FALSE overall.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux