Php else.

Ask about a PHP problem here.
Post Reply
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Php else.

Post by ashwood »

can somebody tell me what is up with this please..
  if($_GET['action']=="changefilter")
  {
    echo "CHANGING FILTER";
  }
  else
  {
    echo "MUSIC";
  }
  else if($_GET['filter']=="hello")
  {
    echo "MUSIC FOR USER...";
  }
  
if i take out the :
  else if($_GET['filter']=="hello")
  {
    echo "MUSIC FOR USER...";
  }
it works but with it.. it doesnt :\..
I would put a signature.. BUT, i don't have the time.
Dominion
Posts: 32
Joined: Thu May 05, 2011 11:32 pm

Re: Php else.. [ SOLVED ]

Post by Dominion »

when using if() {} elseif () {} 's you should only have "else" on it's own for if all if() have failed. having a random else, then an elseif will not work.
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: Php else.. [ SOLVED ]

Post by ashwood »

Dominion wrote:when using if() {} elseif () {} 's you should only have "else" on it's own for if all if() have failed. having a random else, then an elseif will not work.

it works i just had it the wrong way around
I would put a signature.. BUT, i don't have the time.
Dominion
Posts: 32
Joined: Thu May 05, 2011 11:32 pm

Re: Php else.. [ SOLVED ]

Post by Dominion »

ashwood wrote:
Dominion wrote:when using if() {} elseif () {} 's you should only have "else" on it's own for if all if() have failed. having a random else, then an elseif will not work.

it works i just had it the wrong way around
As i said you can't have a random else in the middle of elseif()'s has to be at the end... :lol:
Post Reply