Jiraiya Posted January 13, 2009 Share Posted January 13, 2009 is this look good? its supposed to stop another script on the same page if both variables dont match $UserSL = $UserS['location'] $NPCL = $NPC['location'] if($NPCL = Home) {echo "User is at thier house! <br><br>"; exit(); } if($UserSL = Home) {echo "You must be in the city to fight! <br><br>"; exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/ Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 You need to use == not = in your if statements, and if Home is not a constant surround it in quotes. Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736357 Share on other sites More sharing options...
Jiraiya Posted January 13, 2009 Author Share Posted January 13, 2009 so this then $UserSL = $UserS['location'] $NPCL = $NPC['location'] if($NPCL ==" Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736361 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 Try it and see. so this then Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736399 Share on other sites More sharing options...
Jiraiya Posted January 13, 2009 Author Share Posted January 13, 2009 yea all it did was turn my page white Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736491 Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 $UserSL = $UserS['location']; // syntax error need sem-colon $NPCL = $NPC['location']; // syntax error need sem-colon if($NPCL == "Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); } echo "Begin the fight!"; Should at least echo begin the fight. Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736495 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 Turn on error display and reporting and you would see your errors instead of a white page. yea all it did was turn my page white Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736503 Share on other sites More sharing options...
Jiraiya Posted January 13, 2009 Author Share Posted January 13, 2009 the script is working but its not doing what i need it to do. im trying to get it to verifiy that both variables for both players are both equal to "Forest Of Death" and if either players location variable is not set to "Forest Of Death" i dont want the rest of the script to run here is the whole code $UserSL = $UserS['location']; // syntax error need sem-colon $NPCL = $NPC['location']; // syntax error need sem-colon if($NPCL == "Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); } echo "Begin the fight!"; if(!isset($_GET['user'])) { echo "You have not selected a user to fight!<br><br>"; $NPCS = mysql_query("SELECT * FROM `users`"); while($Show = mysql_fetch_array($NPCS)) { echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>"; } exit(); } $NPC = mysql_escape_string($_GET['user']); $username = $_COOKIE['ID_my_site']; if($_GET[Action] = Attack) { if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();} $UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'"); $UserS = mysql_fetch_array($UserS); $UserH = $UserS['health']; if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();} $UserA = $UserS['skill']; $UserK = $UserS['kills'] +1; $UserSkill = $UserS['skill']; $UserA *= .1; $NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'"); $NPCS = mysql_fetch_array($NPCS); $NPCH = $NPCS['health']; if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();} $NPCA = $NPCS['skill']; $NPCSkill = $NPCS['skill']; $NPCA *= .1; $run = 1; While($run > 0){ $NPCH -= $UserA; if($NPCH <= 0) { $xp = $NPCSkill * .020; echo "You win and have gained " . $xp . " skill from " . $NPC . ""; $UserA = $UserSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kills='$UserK' WHERE username='$username'"); $NPCA = $NPCSkill * .97; mysql_query("UPDATE `users` SET skill='$NPCA', health='0' WHERE username='$NPC'"); exit(); } $UserH -= $NPCA; if($UserH <= 0) { echo "You have lost"; $xp = $UserSkill * .030; $UserA = $NPCSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kill='kill +1' WHERE username='$NPC'"); $UserA = $UserSkill * .97; mysql_query("UPDATE `users` SET skill='$UserA', health='0' WHERE username='$username'"); exit(); } } } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736511 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 I don't see anything that references "Forest Of Death" Also, you need to check all your IF statements, this one is still wrong if($_GET[Action] = Attack) Quote Link to comment https://forums.phpfreaks.com/topic/140691-is-this-done-right/#findComment-736517 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.