Jump to content

Unexpected t_else


Phpfr3ak

Recommended Posts

Wondering what the heck is wrong with it, worked before i varied the error messages, had a pal check it out, he couldn't really spot anything wrong either, obviously were both being blind at what is missing, if someone would be kind enough to explain the segment of code that's causing the error is below.

 

if ($amount < 1);

echo "You must enter the number of troops you wish to hire.";

exit;

}else{

if ($amount > $maxdef);

echo "You cannot hire over your housing limit.";

exit;

}else{

if ($amount = "");

echo "You must enter the number of troops you wish to hire.";

exit;

else

if ($HireCost > $CashOnHand);

echo "You do not have enough cash on hand to hire these troops.";

exit;

Link to comment
https://forums.phpfreaks.com/topic/252715-unexpected-t_else/
Share on other sites

You are using if/else incorrectly. You need to encase everything inside the conditional with curly braces. You are simply using a semicolon after the condition, which is incorrect.

 

if ($amount < 1) {
    echo "You must enter the number of troops you wish to hire.";
    exit();
}else{
    // blah blah
}

Link to comment
https://forums.phpfreaks.com/topic/252715-unexpected-t_else/#findComment-1295561
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.