You are here: Re: Using the OR operator in an IF statement « PHP « IT news, forums, messages
Re: Using the OR operator in an IF statement

Posted by Greg Beaver on 01/08/05 14:36

Tim Burgan 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") )
> {
> // ...
> }
> ?>

use && instead of ||

In english, you'd say "if the usertype is not student and not staff and
not admin, then we're OK." or "if the usertype is neither student, nor
staff, nor admin"

neither/nor is implemented using !=/&&

Greg

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация