Aces Posted March 11, 2008 Share Posted March 11, 2008 Hi there.. I'm having problems with this error and can't seem to fix it I have looked over the coding for a while now and am stumped ??? Can anyone help plz? <? session_start(); include("gameconfig.php"); $title = "Doing crimes"; if(!$email || !$password){ error("field"); exit; } if($playerinfo[password] != $password){ error("password"); }else{ include("top.php"); $_GET['c']=abs((int) $_GET['c']); if(!$_GET['c']) { print "Invalid crime"; } else { $q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}"); $r=mysql_fetch_array($q); if($playerinfo['nerve'] < $r['crimeBRAVE']) { print "You do not have enough Brave to perform this crime."; } else { if($playerinfo['crimes'] > $r['crimePERCFORM']); print "$r[crimeSTEXT]"; } else { print "$r[crimeFTEXT]"; } print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br /> <a href='crim.php'>Crimes</a>"; } } include("bottom.php"); } ?> This is the error i get... Parse error: syntax error, unexpected T_ELSE in /****/*******/************/*******.php on line 39 thanks Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/ Share on other sites More sharing options...
Orio Posted March 11, 2008 Share Posted March 11, 2008 You have a semicolon after your if on line 36. Delete it and you should be fine. EDIT- you seem to have too many elses anyway... Try tabbing and spacing your code, this way you'll have a better chance to figure out where your logic went wrong Orio. Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489625 Share on other sites More sharing options...
Aces Posted March 11, 2008 Author Share Posted March 11, 2008 Thanks for the fast reply but even after moving the ; i still get the same error Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489630 Share on other sites More sharing options...
Orio Posted March 11, 2008 Share Posted March 11, 2008 Read my edit above.. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489633 Share on other sites More sharing options...
trq Posted March 11, 2008 Share Posted March 11, 2008 Its pretty hard to read the logic of your code because there is no indentation. If you indented your code properly, your errors would become allot more obvious. Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489636 Share on other sites More sharing options...
peranha Posted March 11, 2008 Share Posted March 11, 2008 Also open all your pages with <?php not the short version <? Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489639 Share on other sites More sharing options...
soycharliente Posted March 11, 2008 Share Posted March 11, 2008 EDIT- you seem to have too many elses anyway... Try tabbing and spacing your code, this way you'll have a better chance to figure out where your logic went wrong The elses are fine. I've tabbed it out. Here's his code. <?php session_start(); include("gameconfig.php"); $title = "Doing crimes"; if(!$email || !$password) { error("field"); exit; } if($playerinfo[password] != $password) { error("password"); } else { include("top.php"); $_GET['c']=abs((int) $_GET['c']); if(!$_GET['c']) { print "Invalid crime"; } else { $q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}"); $r=mysql_fetch_array($q); if($playerinfo['nerve'] < $r['crimeBRAVE']) { print "You do not have enough Brave to perform this crime."; } else { if($playerinfo['crimes'] > $r['crimePERCFORM']) { print "$r[crimeSTEXT]"; } else { print "$r[crimeFTEXT]"; } print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br /><a href='crim.php'>Crimes</a>"; } } include("bottom.php"); } ?> Maybe part of the problem is this line? $_GET['c']=abs((int) $_GET['c']); Can you do that? Resave to the $_GET variable? Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489648 Share on other sites More sharing options...
redarrow Posted March 11, 2008 Share Posted March 11, 2008 <?php session_start(); include("gameconfig.php"); $title = "Doing crimes"; if(!$email || !$password){ error("field"); exit; } if($playerinfo[password] != $password){ error("password"); }else{ include("top.php"); } $_GET['c']=abs((int) $_GET['c']); if(!$_GET['c']) { print "Invalid crime"; } $q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}"); $r=mysql_fetch_array($q); if($playerinfo['nerve'] < $r['crimeBRAVE']) { print "You do not have enough Brave to perform this crime."; }elseif ($playerinfo['crimes'] > $r['crimePERCFORM']){ print $r['crimeSTEXT']; }else{ print "$r[crimeFTEXT]"; print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br /> <a href='crim.php'>Crimes</a>"; } include("bottom.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489652 Share on other sites More sharing options...
Aces Posted March 11, 2008 Author Share Posted March 11, 2008 That worked great thanks redarrow I see you replaced a "else" with a "elseif" was that the problem? Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489653 Share on other sites More sharing options...
Orio Posted March 11, 2008 Share Posted March 11, 2008 The elses are fine. I've tabbed it out. Here's his code. You've changed it. The problem was here: else { if($playerinfo['crimes'] > $r['crimePERCFORM']); print "$r[crimeSTEXT]"; } else { print "$r[crimeFTEXT]"; } As you can see, there's a else{}else{} structure. @Aces - try using the code charlieholder posted or maybe redarrow's (I didn't go over that one). Orio. Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489655 Share on other sites More sharing options...
soycharliente Posted March 11, 2008 Share Posted March 11, 2008 I replaced the ; with a { since the keys are right next to each other. That seemed to be the logical fix. Quote Link to comment https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489718 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.