Monk3h Posted March 19, 2008 Share Posted March 19, 2008 This error has been annoying for far too long now.. Stupid little things keep going wrong with my script when i change the slightest things and i have no idea why!? Heres the Code: <?php $title = "The Safety Deposit Boxes"; include ("header.php"); ?> <?php if ($stat[travelpass] <= N ) { Print "<b>Dusty old man:</b> You shouldnt be down here without a Travel Pass! Shoo, before i get you banned from here Completely!"; } else { Print "<b>Dusty old man:</b> Welcome the Safety Deposit Box Area, not many people come down here anymore.. Well then, Whats ya business?"; print "<ul>"; print "<li><a href=box.php?action=box>Open a box</a>"; print "</ul>"; if ($action == box) { $chance = rand(1,; mysql_query("update players set keys=keys-1 where id=$stat[id]"); if ($chance == 1) { print "As you turn the key in the lock you here a faint fluttering sound.. Nothing here but butterflies!"; } if ($chance == 2) { print "You found a <i>Diamond!</i>.. No wait, thats just a shiney rock."; } if ($chance == 3) { $crgain = rand(1,10000); print "Credits, millions of them! <b>$crgain</b> to be more precise."; mysql_query("update players set credits=credits+$crgain where id=$stat[id]"); } if ($chance == 4) { print "Nothin' interesting can be seen."; } if ($chance == 5) { print "What was that?"; } if ($chance == 6) { $plgain = rand(1,100); print "Pft.. Just a lump of ore.. No wait! Thats no ordinary ore! You found <b>$plgain</b> platinum."; mysql_query("update players set platinum=platinum+$plgain where id=$stat[id]"); } if ($chance == 7) { $roll = rand(1,20); if ($roll == 15) { print "As you open the box door the stench of Stagnent Water overwhelms your sences! Inside you fine a vile or murky liquid."; mysql_query("update players set elixer=elixer+1 where id=$stat[id]"); } else { print "Ewwwwww! its a dead fish! Cant of been here for long as it seems to still be edible! <b>1</b> Bass gained!"; mysql_query("update players set bass=bass+1 where id=$stat[id]"); } } if ($chance == { print "The key breaks off in the lock.."; } $keysleft = ($stat[keys] - 1); print "<br><br>... <a href=box.php?action=box>Open</a> another box? (<b>$keysleft</b> Keys left.)"; } } else { print "<b>Dusty old man:</b> You dont have the key for that box, infact you dont have a key for any of these Boxes, get outa here! <br><br> <a href=travel.php>Leave</a>"; } ?> <?php include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted March 19, 2008 Share Posted March 19, 2008 this is the problem in bold if ($stat[travelpass] <= N ) { Print "Dusty old man: You shouldnt be down here without a Travel Pass! Shoo, before i get you banned from here Completely!"; } else { Print "Dusty old man: Welcome the Safety Deposit Box Area, not many people come down here anymore.. Well then, Whats ya business?"; -------------- you can just have an "else" keyword on its own line...try this: } else { Quote Link to comment Share on other sites More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 Any clue to the line number? Also, on this line.... if ($stat[travelpass] <= N ) { What is N ? Quote Link to comment Share on other sites More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 this is the problem in bold if ($stat[travelpass] <= N ) { Print "Dusty old man: You shouldnt be down here without a Travel Pass! Shoo, before i get you banned from here Completely!"; } else { Print "Dusty old man: Welcome the Safety Deposit Box Area, not many people come down here anymore.. Well then, Whats ya business?"; -------------- you can just have an "else" keyword on its own line...try this: } else { Indeed it is pefectly valid sytax to use... if ($exp) { // do something } else { // do something else. } Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted March 19, 2008 Share Posted March 19, 2008 this is the problem in bold if ($stat[travelpass] <= N ) { Print "Dusty old man: You shouldnt be down here without a Travel Pass! Shoo, before i get you banned from here Completely!"; } else { Print "Dusty old man: Welcome the Safety Deposit Box Area, not many people come down here anymore.. Well then, Whats ya business?"; -------------- you can just have an "else" keyword on its own line...try this: } else { Indeed it is pefectly valid sytax to use... if ($exp) { // do something } else { // do something else. } Hmm....I've tried that before and got a similar error...thats why i thought it was invalid Quote Link to comment Share on other sites More sharing options...
Monk3h Posted March 19, 2008 Author Share Posted March 19, 2008 Changing it to } else { Just moved the error down a line.. :/ the if ($stat[travelpass] <= N ) { is the make sure the user has the pass needed to be in that area.. Edit: I missunderstood what you said and have tried chaging both Else to } else { and } else { Nether worked.. Quote Link to comment Share on other sites More sharing options...
Monk3h Posted March 19, 2008 Author Share Posted March 19, 2008 Too keep things clear.. <?php $title = "The Safety Deposit Boxes"; include ("header.php"); ?> <?php if ($stat[travelpass] <= N ) { Print "<b>Dusty old man:</b> You shouldnt be down here without a Travel Pass! Shoo, before i get you banned from here Completely!"; } else { Print "<b>Dusty old man:</b> Welcome the Safety Deposit Box Area, not many people come down here anymore.. Well then, Whats ya business?"; print "<ul>"; print "<li><a href=box.php?action=box>Open a box</a>"; print "</ul>"; if ($action == box) { $chance = rand(1,; mysql_query("update players set keys=keys-1 where id=$stat[id]"); if ($chance == 1) { print "As you turn the key in the lock you here a faint fluttering sound.. Nothing here but butterflies!"; } if ($chance == 2) { print "You found a <i>Diamond!</i>.. No wait, thats just a shiney rock."; } if ($chance == 3) { $crgain = rand(1,10000); print "Credits, millions of them! <b>$crgain</b> to be more precise."; mysql_query("update players set credits=credits+$crgain where id=$stat[id]"); } if ($chance == 4) { print "Nothin' interesting can be seen."; } if ($chance == 5) { print "What was that?"; } if ($chance == 6) { $plgain = rand(1,100); print "Pft.. Just a lump of ore.. No wait! Thats no ordinary ore! You found <b>$plgain</b> platinum."; mysql_query("update players set platinum=platinum+$plgain where id=$stat[id]"); } if ($chance == 7) { $roll = rand(1,20); if ($roll == 15) { print "As you open the box door the stench of Stagnent Water overwhelms your sences! Inside you fine a vile or murky liquid."; mysql_query("update players set elixer=elixer+1 where id=$stat[id]"); } else { print "Ewwwwww! its a dead fish! Cant of been here for long as it seems to still be edible! <b>1</b> Bass gained!"; mysql_query("update players set bass=bass+1 where id=$stat[id]"); } } if ($chance == { print "The key breaks off in the lock.."; } $keysleft = ($stat[keys] - 1); print "<br><br>... <a href=box.php?action=box>Open</a> another box? (<b>$keysleft</b> Keys left.)"; } } else { print "<b>Dusty old man:</b> You dont have the key for that box, infact you dont have a key for any of these Boxes, get outa here! <br><br> <a href=travel.php>Leave</a>"; } ?> <?php include("footer.php"); ?> Error: Parse error: syntax error, unexpected T_ELSE in /home/monk3h/public_html/box.php on line 59 Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 what is N? it's not a legal variable name (no dollar sign in front). do you declare it as a constant somewhere we can't see? Quote Link to comment Share on other sites More sharing options...
Monk3h Posted March 19, 2008 Author Share Posted March 19, 2008 N is content in my database, that is not the problem i am 100% sure of this as im using the same thing in other working scripts. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 the unexpected ELSE is lower in the code: } } else { print "...... i suggest indenting your code and using an editor that lets you know if you've got unmatched {}'s Quote Link to comment Share on other sites More sharing options...
Monk3h Posted March 19, 2008 Author Share Posted March 19, 2008 Any sugestions on a good Editor? At the moment im using Crimson Editor and Notepad. Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 19, 2008 Share Posted March 19, 2008 You don't seem to have closed said Else. Quote Link to comment 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.