Xyphon Posted December 24, 2007 Share Posted December 24, 2007 Okay, I finally got map to wok a bit, but then it made my code show both caught and catch on the same page because I didnt exit. So I exit and now the only page it'll ever display is the Nothing found page.. Heres the code: <?PHP session_start(); include('Connect.php'); include('top.php'); $ID= $_COOKIE['UserID']; //If User Is Not Logged In if(!isset($ID)) { //Display Message echo "Sorry, you are not logged in.<br /><br /><a href='login.php'>Login</a>"; //Include Bottom File include("bottom.php"); //Exit Page exit; } $Action= $_GET['action']; $Submit= $_POST['Submit']; $Result1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'"); $Rows1= mysql_fetch_array($Result1); //If User Has No Pokémon if(empty($Rows1)) { //Display Message echo "Sorry, you must obtain your starter first.<br /><br /><a href='obtainstarter.php'>Obtain Starter</a>"; //Include Bottom File include("bottom.php"); //Exit Page exit; } //Find Position Results $AP_PResult1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='1'"); $AP_PResult2= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='2'"); $AP_PResult3= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='3'"); $AP_PResult4= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='4'"); $AP_PResult5= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='5'"); $AP_PResult6= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='6'"); //Find Position Rows $AP_PRows1= mysql_fetch_array($AP_PResult1); $AP_PRows2= mysql_fetch_array($AP_PResult2); $AP_PRows3= mysql_fetch_array($AP_PResult3); $AP_PRows4= mysql_fetch_array($AP_PResult4); $AP_PRows5= mysql_fetch_array($AP_PResult5); $AP_PRows6= mysql_fetch_array($AP_PResult6); //Set Position Variable $AP_MainPosition="No"; //Find Position One if(empty($AP_PRows1)) { //If Main Position Is No if($AP_MainPosition=="No") { //Define Variables $AP_Slot= 1; $AP_MainPosition="Yes"; } } //Find Position Two elseif(empty($AP_PRows2)) { //If Main Position Is No if($AP_MainPosition=="No") { //Define Variables $AP_Slot= 2; $AP_MainPosition="Yes"; } } //Find Position Three elseif(empty($AP_PRows3)) { //If Main Position Is No if($AP_MainPosition=="No") { //Define Variables $AP_Slot= 3; $AP_MainPosition="Yes"; } } //Find Position Four elseif(empty($AP_PRows4)) { //If Main Position Is No if($AP_MainPosition=="No") { //Define Variables $AP_Slot= 4; $AP_MainPosition="Yes"; } } //Find Position Five elseif(empty($AP_PRows5)) { //If Main Position Is No if($AP_MainPosition=="No") { //Define Variables $AP_Slot= 5; $AP_MainPosition="Yes"; } } //Find Position Six elseif(empty($AP_PRows6)) { //If Main Position Is No if($AP_MainPosition=="No"); { //Define Variables $AP_Slot= 6; $AP_MainPosition="Yes"; } } //Find Box Position else { //Define Variables $AP_Slot= 7; $AP_MainPosition="Yes"; } if(!isset($Action)) { if(!isset($_SESSION['rand']) ) { $PokemonRand= rand(1, 99); $_SESSION['rand'] = $PokemonRand; } if($PokemonRand < 75 && $PokemonRand > 50) { $pokemonname="Magby"; $sorrymessage="<img border='0' src='http://i10.tinypic.com/8also6f.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(12,27); $defence= rand(15,23); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonicon="http://i9.tinypic.com/6owv9l0.png"; $pokemonimage="http://i10.tinypic.com/8also6f.png"; } elseif($PokemonRand < 100 && $PokemonRand > 74 ) { $pokemonname="Charmander"; $sorrymessage="<img border='0' src='http://i13.tinypic.com/6xvsvw7.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(15,23); $defence= rand(12,27); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonicon="http://i13.tinypic.com/6l2w8l2.png"; $pokemonimage="http://i13.tinypic.com/6xvsvw7.png"; } elseif($PokemonRand < 51 && $PokemonRand > 49 ) { $pokemonname="Entei"; $sorrymessage="<img border='0' src='http://i8.tinypic.com/7xxnyud.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(20,37); $defence= rand(23,34); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonimage="http://i8.tinypic.com/7xxnyud.png"; $pokemonicon="http://i2.tinypic.com/6wp5cmq.png"; } else { $sorrymessage="Nothing found. Keep looking."; } $pokemonrand2= $_SESSION['rand2']; //If Gender Is Male if(!isset($_SESSION['rand2']) ) { $pokemonrand2= rand(1, 99); $_SESSION['rand2'] = $pokemonrand2; } if($pokemonrand2 < 50 && $pokemonrand2 > 0) { //Define Promo Variables $pokemongender="Male"; } //If Gender Is Female elseif($pokemonrand2 < 99 && $pokemonrand2 > 50) { //Define Promo Variables $pokemongender="Female"; } //If Promo Is Ungendered else { //Define Promo Variables $pokemongender="Ungendered"; } echo "$sorrymessage<br />"; echo "Click on the map to find pokemon!<br />"; echo "<a href='mapbeta.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>"; } include('bottom.php'); die(); if(isset($Action)) { $PokemonRand = $_SESSION['rand']; } if($PokemonRand < 75 && $PokemonRand > 50) { $pokemonname="Magby"; $sorrymessage="<img border='0' src='http://i10.tinypic.com/8also6f.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(12,27); $defence= rand(15,23); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonicon="http://i9.tinypic.com/6owv9l0.png"; $pokemonimage="http://i10.tinypic.com/8also6f.png"; } elseif($PokemonRand < 100 && $PokemonRand > 74 ) { $pokemonname="Charmander"; $sorrymessage="<img border='0' src='http://i13.tinypic.com/6xvsvw7.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(15,23); $defence= rand(12,27); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonicon="http://i13.tinypic.com/6l2w8l2.png"; $pokemonimage="http://i13.tinypic.com/6xvsvw7.png"; } elseif($PokemonRand < 51 && $PokemonRand > 49 ) { $pokemonname="Entei"; $sorrymessage="<img border='0' src='http://i8.tinypic.com/7xxnyud.png'><br />Pokemon found! Want to catch?<form action='mapbeta.php?action=catch' method='POST'> <input type='hidden' name='Submit' value='1'> <input type='submit' value='Catch!'> </form>"; $attack= rand(20,37); $defence= rand(23,34); $level= rand(1,15); $EXP="0"; $NEXP= rand(27,52); $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $pokemonimage="http://i8.tinypic.com/7xxnyud.png"; $pokemonicon="http://i2.tinypic.com/6wp5cmq.png"; } else { $sorrymessage="Nothing found. Keep looking."; $pokemonrand2= $_SESSION['rand2']; //If Gender Is Male } if($pokemonrand2 < 50 && $pokemonrand2 > 0) { //Define Promo Variables $pokemongender="Male"; } //If Gender Is Female elseif($pokemonrand2 < 99 && $pokemonrand2 > 50) { //Define Promo Variables $pokemongender="Female"; } //If Promo Is Ungendered else { //Define Promo Variables $pokemongender="Ungendered"; } echo "You caught the Pokemon!<br />"; echo "Click on the map to find pokemon!<br />"; echo "<a href='mapbeta.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>"; mysql_query("INSERT INTO pokemon_info (user_id, pokemon_name, pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon, pokemon_level, pokemon_exp, pokemon_nexp, attack1, attack2, attack3, attack4, pokemon_slot) VALUES ('$ID', '$pokemonname', '$attack', '$defence', '$pokemonimage', '$pokemongender', '$pokemonicon', '$level', '$EXP', '$NEXP', '$attack1', '$attack2', '$attack3', '$attack4', '$AP_Slot')")or die(mysql_error()); unset($_SESSION['rand']); unset($_SESSION['rand2']); session_unset(); session_destroy(); include('bottom.php'); ?> Can you help me? Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/ Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 Narrow your code down to the relevent parts. Also, you'll need to be alot clearer in the description of your problem, you talk about maps, but I have no idea what your refering too. ps: Your code is terribly inificient. Look at this.... $AP_PResult1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='1'"); $AP_PResult2= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='2'"); $AP_PResult3= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='3'"); $AP_PResult4= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='4'"); $AP_PResult5= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='5'"); $AP_PResult6= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='6'"); that sort of logic is rediculous. Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422135 Share on other sites More sharing options...
Xyphon Posted December 24, 2007 Author Share Posted December 24, 2007 Narrow your code down to the relevent parts. Also, you'll need to be alot clearer in the description of your problem, you talk about maps, but I have no idea what your refering too. ps: Your code is terribly inificient. Look at this.... $AP_PResult1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='1'"); $AP_PResult2= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='2'"); $AP_PResult3= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='3'"); $AP_PResult4= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='4'"); $AP_PResult5= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='5'"); $AP_PResult6= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID' AND pokemon_slot='6'"); that sort of logic is rediculous. That my friend is checking the pokemon slots. You know catching pokemon? Thats maps. The error is the exit, as in, I keep clicking the map and no matter what it wont display a pokemon thats found, it'll just keep saying ntohing found. Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422137 Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 That my friend is incredibly poor code. You are running 6 queries where one is needed. Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422146 Share on other sites More sharing options...
dewey_witt Posted December 24, 2007 Share Posted December 24, 2007 I agree a loop is needed to loop through the results. It will also make the script alot faster... how long is it taking to load? LOL Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422151 Share on other sites More sharing options...
Xyphon Posted December 24, 2007 Author Share Posted December 24, 2007 That my friend is incredibly poor code. You are running 6 queries where one is needed. How is 1 needed, I need 2 have 1 variable for every pokemon slot. Anyways, thats not the problem, the problem is the exit part. And sometimes it insta loads. Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422350 Share on other sites More sharing options...
Xyphon Posted December 24, 2007 Author Share Posted December 24, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422434 Share on other sites More sharing options...
Xyphon Posted December 24, 2007 Author Share Posted December 24, 2007 Hello? Quote Link to comment https://forums.phpfreaks.com/topic/82996-having-a-problem/#findComment-422585 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.