Page 1 of 1

variable and comparison operator problem[solved]

Posted: Sun Jan 14, 2007 3:48 pm
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

Posted: Sun Jan 14, 2007 3:53 pm
by feyd

Code: Select all

$_SESSION['c_name'] == 'admin' or $_SESSION['c_name'] == 'master'

Posted: Sun Jan 14, 2007 3:54 pm
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
{}

Posted: Sun Jan 14, 2007 4:05 pm
by coolmoon
thanks for the replys

feyd

decipher