[thelist] [php] Using the OR operator in an IF statement

Rick rick.good at shiesl.com
Sat Jan 8 05:59:32 CST 2005


I think you need to use AND rather than OR. Rick

On 1/8/05 12:16 PM, "Tim Burgan" <email at timburgan.com> wrote:

> Hello,
> 
> 
> Can someone please correct me on my efforts below.
> If I have a condition where I want to test if a variable is not equal to
> "student", "staff", or "admin".. what's the simplest was to achieve that?
> 
> Here's what I tried.. that didn't work:
> 
> <?php
> if ( ($_POST['usertype'] != "student") || ($_POST['usertype'] !=
> "staff") ||  ($_POST['usertype'] != "admin") )
> {
>    // ...
> }
> ?>
> 
> And also:
> 
> <?php
> if ( ($_POST['usertype'] != "student" || "staff" || "admin" )
> {
>    // ...
> }
> ?>
> 
> I must be using the OR operator the wrong way. Can someone please
> correct me on this.
> 
> Thanks very much for your time.
> 
> 
> Regards
> 
> Tim Burgan
> 

-- 
³Always be careful when you pray, because deity is listening and will
usually give you what you ask for, not what you meant to ask for. Goddess
grant us good luck and a fertile winter.² Merry, Page 348, A Caress of
Twilight by Laurell K. Hamilton.



More information about the thelist mailing list