Jump to content

case:


grlayouts

Recommended Posts

when i run the following i get. Parse error: syntax error, unexpected T_CASE in intrain.php on line #

 

                <?php
print "<form method=post action=intrain.php?view=train&step=trainingturns>Use<input name=amount>Energy Training On <select name=training><option value=weights>Weights</option><option value=agility>Tredmill</option></select>. <input type=submit value=Buy></form>";
if (isset($_POST)){
switch($_POST['training'])
{
	case "weights":
		if ($stat[energy] < $amount) {
print "<br>Your going to need $amount to train that hard.";
}
elseif ($stat[hp] < 1.0) {
print "<br>You cant train unless you are alive you loser.";
} else {
$chance = rand(1,10);
$chance13 = rand(1,2) / 700 / $stat[level] * $amount;
$chance14 = rand(3,5) / 700 / $stat[level] * $amount;
if ($chance == 1) {
print "<center>Man you were so bad in the gym<bR> you got kicked out for slacking<br>next time actually do some weights.";
mysql_query("update players set energy=energy-$amount where id=$stat[id]");
} else {
print " <center>Hey $stat[user] i never knew you were that fast!<br> you should come here more often if you want to stay in that condition<bR>You gained $chance14 strength<br>and $chance13 agility<br> <a href=intrain.php?action=tredmill>Run Again</a><bR><br> ";
mysql_query("update players set strength=strength+$chance14 where id=$stat[id]");
mysql_query("update players set agility=agility+$chance13 where id=$stat[id]");
mysql_query("update players set energy=energy-$amount where id=$stat[id]");
			}
			}
			}
}
break;
	case "agilty":
		if ($stat[energy] < $amount) {
print "<br>Your going to need $amount to train that hard.";
}
elseif ($stat[hp] < 1.0) {
print "<br>You cant train unless you are alive you loser.";
} else {
$chance = rand(1,10);
$chance13 = rand(1,2) / 700 / $stat[level] * $amount;
$chance14 = rand(3,5) / 700 / $stat[level] * $amount;
if ($chance == 1) {
print "<center>Man you were so bad in the gym<bR> you got kicked out for slacking<br>next time actually do some weights.";
mysql_query("update players set energy=energy-$amount where id=$stat[id]");
} else {
print " <center>Hey $stat[user] i never knew you were that fast!<br> you should come here more often if you want to stay in that condition<bR>You gained $chance14 strength<br>and $chance13 agility<br> <a href=intrain.php?action=tredmill>Run Again</a><bR><br> ";
mysql_query("update players set strength=strength+$chance13 where id=$stat[id]");
mysql_query("update players set agility=agility+$chance14 where id=$stat[id]");
mysql_query("update players set energy=energy-$amount where id=$stat[id]");
			}
			}
			}
}
?>

Link to comment
Share on other sites

try removing 2 right curlies before the first break.

 

indent your code and you'll see the extras:

 

if ($stat[energy] < $amount) {
print "<br>Your going to need $amount to train that hard.";
} elseif ($stat[hp] < 1.0) {
print "<br>You cant train unless you are alive you loser.";
} else {
$chance = rand(1,10);
$chance13 = rand(1,2) / 700 / $stat[level] * $amount;
$chance14 = rand(3,5) / 700 / $stat[level] * $amount;
if ($chance == 1) {
	print "<center>Man you were so bad in the gym<bR> you got kicked out for slacking<br>next time actually do some weights.";
	mysql_query("update players set energy=energy-$amount where id=$stat[id]");
} else {
	print " <center>Hey $stat[user] i never knew you were that fast!<br> you should come here more often if you want to stay in that condition<bR>You gained $chance14 strength<br>and $chance13 agility<br> <a href=intrain.php?action=tredmill>Run Again</a><bR><br> ";
	mysql_query("update players set strength=strength+$chance14 where id=$stat[id]");
	mysql_query("update players set agility=agility+$chance13 where id=$stat[id]");
	mysql_query("update players set energy=energy-$amount where id=$stat[id]");
}
}
}
}
break;

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.