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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.