views:

272

answers:

4

I'm using an if statement to declare whether a user is an admin, mod or neither with this code below, but its messing up by always making $status = "admin" even if that person is neither, this has really baffled me.

if($info['rights'] == "m") {
    $status = '<font color="#FFFFFF">(mod)</font>';
}elseif ($info['rights'] == "a"); {
    $status = '<font color="#FFFFFF">(admin)</font>';
}
+16  A: 

You seem to have accidentaly added a semicolon (;) after the elseif, so the second code block is always getting executed.

Aistina
Yeah, get rid of the semicolon on line 3 and everything should work as planned.
BoltBait
+4  A: 

Is there supposed to be a semi-colon after "a")?

Ankur
Thanks guys it's working now, I feel stupid :P
Ryan
@Ryan : you should, i spent a month trying to figure out what i had done wrong in a code. in one file i had $bla and in the other $b1a
dassouki
+1  A: 

Is $info declared? Where is $info defined and assigned?

+2  A: 

You have a syntax error in your code.

You can try this:

if($info['rights'] == "m") {
  $status = '<font color="#FFFFFF">(mod)</font>';
} else if ($info['rights'] == "a") {
  $status = '<font color="#FFFFFF">(admin)</font>';
}
shuxer
protip: Spell the word "you" out using all three letters.
recursive
why i have to use 'You' if save my ms times with just 'U' ?
shuxer
Because saying u instead of you makes you sound like a 13 yr old girl chatting to her friends on AIM.
ryeguy