grlayouts Posted September 23, 2007 Share Posted September 23, 2007 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]"); } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/ Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 what's the number after line #??? check your right curly brackets. they don't look matched in the first case. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353583 Share on other sites More sharing options...
grlayouts Posted September 23, 2007 Author Share Posted September 23, 2007 214 which realates to line case "agilty": Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353584 Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 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; Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353585 Share on other sites More sharing options...
grlayouts Posted September 23, 2007 Author Share Posted September 23, 2007 did that as you said now completing but not doing the sql updates or prints. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353587 Share on other sites More sharing options...
trq Posted September 23, 2007 Share Posted September 23, 2007 Can you format (indent) your code in logical blocks so it is readable and then post it again? You might also want to wrap some error checking around those calls to mysql_query() to see if there is a problem. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353588 Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 also: is $_POST['training'] either of the 2 cases? echo it and see. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353589 Share on other sites More sharing options...
grlayouts Posted September 23, 2007 Author Share Posted September 23, 2007 post training is for the drop down then the two cases are inside, weights and agility. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353590 Share on other sites More sharing options...
grlayouts Posted September 23, 2007 Author Share Posted September 23, 2007 training echo's nothing. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353594 Share on other sites More sharing options...
trq Posted September 23, 2007 Share Posted September 23, 2007 training echo's nothing. More than likely because your form is made up of invalid html. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353605 Share on other sites More sharing options...
grlayouts Posted September 23, 2007 Author Share Posted September 23, 2007 invalid? the first case works fine only the second fails. Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353607 Share on other sites More sharing options...
grlayouts Posted September 24, 2007 Author Share Posted September 24, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/70386-case/#findComment-353849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.