variable and comparison operator problem[solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
coolmoon
Forum Newbie
Posts: 4
Joined: Sun Jan 07, 2007 9:30 am

variable and comparison operator problem[solved]

Post by coolmoon »

hey all,

so i am trying to do somthing like this

Code: Select all

$_SESSION['c_name']  = "admin";

    if ($_SESSION['c_name'] == 'admin') 
                {
                      redirect
                }
    else
                {
                      redirect
                {
which evaluates true but i want to do


Code: Select all

if    ($_SESSION['c_name'] == ('admin' || 'master')) 
                {
                      redirect
                }
     else
                {
                     redirect
                {
but it evaluates false

I have tried, with and without quotes, "or" instead of ||
and just about every thing else I can think of or read


just looking for direction

Thanks coolmoon
Last edited by coolmoon on Sun Jan 14, 2007 5:11 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$_SESSION['c_name'] == 'admin' or $_SESSION['c_name'] == 'master'
decipher
Forum Commoner
Posts: 38
Joined: Mon Mar 13, 2006 6:27 am
Location: south africa

Post by decipher »

Code: Select all

if    ($_SESSION['c_name'] == ('admin' || 'master'))
                {
                      redirect
                }
     else
                {
                     redirect
                }
That code will lot work.
You need to have it as if ((currentvalue == value) or (currentvalue == value2))
so the correct code would be:

Code: Select all

if (($_SESSION['c_name'] == 'admin') ||  ($_SESSION['c_name'] == 'master'))
{}
else
{}
coolmoon
Forum Newbie
Posts: 4
Joined: Sun Jan 07, 2007 9:30 am

Post by coolmoon »

thanks for the replys

feyd

decipher
Post Reply