Page 1 of 1

Php else.

Posted: Fri Jun 03, 2011 11:29 am
by ashwood
can somebody tell me what is up with this please..
[syntax=php]
if($_GET['action']=="changefilter")
{
echo "CHANGING FILTER";
}
else
{
echo "MUSIC";
}
else if($_GET['filter']=="hello")
{
echo "MUSIC FOR USER...";
}
[/syntax]

if i take out the :

[syntax=php] else if($_GET['filter']=="hello")
{
echo "MUSIC FOR USER...";
}[/syntax]

it works but with it.. it doesnt :\..

Re: Php else.. [ SOLVED ]

Posted: Fri Jun 03, 2011 12:51 pm
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.

Re: Php else.. [ SOLVED ]

Posted: Fri Jun 03, 2011 12:53 pm
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

Re: Php else.. [ SOLVED ]

Posted: Fri Jun 03, 2011 12:54 pm
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: