Re: if statement with or comparison (newbie)
| From: | Prathaban Mookiah | Date: | Fri, 08 Sep 2006 21:28:41 +0000 |
| Subject: | Re: if statement with or comparison (newbie) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241505@lists.php.net to get a copy of this message | ||
Let me rephrase it. Your color should be black or white to be the right
colour. Is this correct?
In that case you should change it to
if ($_REQUEST['id'] != "black" AND $_REQUEST['id'] !=
"white") {
echo "wrong color";
} else (
echo "right color";
}
----- Original Message -----
From: "JD" <jd_borozo@borozo.com>
To: <php-general@lists.php.net>
Sent: Friday, September 08, 2006 5:03 PM
Subject: [PHP] if statement with or comparison (newbie)
> I'm trying to set up a simple conditional, something like this:
>
> If my_variable is NOT equal to (black or white)
> echo "wrong color"
> else
> echo "right color"
>
> Here is what I have tried:
>
> if ($_REQUEST['id'] != ("black" or "white")) {
>
> echo "wrong color";
>
> } else (
>
> echo "right color";
>
> )
>
> However, no matter what I enter, I always get response "right color".
>
> I should add that if I change the if statement to:
>
> if ($_REQUEST['id'] != ("black"))
>
> then I get "right color" when I enter "black" and "wrong color"
> for
> everything else.
>
> Would you please point out what's the trivial thing I'm missing here...
>
> jd
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>