Jump to content

Recommended Posts

<?PHP
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'];
$Result1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'");
$Rows1= mysql_fetch_array($Result1);
$PokemonRand= rand(1, 99);

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='map1find.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='map1find.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='map1find.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= rand(1, 99);

//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";
}
//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))
{
echo "$sorrymessage<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
}
else
{
echo "You caught the Pokemon!<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.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());
}


include('bottom.php');
?>

 

Well, the problem is, it rands twice. Meaning they'll go to catch Charmander, and might get Magby. Can you help?

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/
Share on other sites

I'm nice so here:

<?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'];
$Result1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'");
$Rows1= mysql_fetch_array($Result1);
$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='map1find.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='map1find.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='map1find.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['rand'];

//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";
}
//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))
{
echo "$sorrymessage<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
}
else
{
echo "You caught the Pokemon!<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.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());
}


include('bottom.php');
?>

Just updated it.

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-421423
Share on other sites

Change this

$PokemonRand= rand(1, 99);
$_SESSION['rand'] = $PokemonRand;

To

if(!isset($_SESSION['rand']) ) {
    $PokemonRand= rand(1, 99);
    $_SESSION['rand'] = $PokemonRand;
}

You will need to unset $_SESSION['rand'] every time you want rerun the script with a new random number

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-421431
Share on other sites

Change this

$PokemonRand= rand(1, 99);
$_SESSION['rand'] = $PokemonRand;

To

if(!isset($_SESSION['rand']) ) {
    $PokemonRand= rand(1, 99);
    $_SESSION['rand'] = $PokemonRand;
}

You will need to unset $_SESSION['rand'] every time you want rerun the script with a new random number

Good catch. Never recognized that problem (its late here lol)

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-421433
Share on other sites

<?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'];
$Result1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'");
$Rows1= mysql_fetch_array($Result1);
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.";
}
unset($_SESSION['rand']);
$pokemonrand2= $_SESSION['rand'];

//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";
}
unset($_SESSION['rand2']);
//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))
{
echo "$sorrymessage<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
}
else
{
session_unset(); 
echo "You caught the Pokemon!<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.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());
}


include('bottom.php');
?>

 

Still rands twice. Can someone fix it?

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-421506
Share on other sites

It doesnt say that anymore, it says this if(!isset($_SESSION['rand']) ) {

    $PokemonRand= rand(1, 99);

    $_SESSION['rand'] = $PokemonRand;

}

 

This is 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'];
$Result1= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'");
$Rows1= mysql_fetch_array($Result1);
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.";
}
unset($_SESSION['rand']);
$pokemonrand2= $_SESSION['rand'];

//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";
}
unset($_SESSION['rand2']);
//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))
{
echo "$sorrymessage<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.php'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
}
else
{
session_unset(); 
echo "You caught the Pokemon!<br />";
echo "Click on the map to find pokemon!<br />";

echo "<a href='map1find.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());
}


include('bottom.php');
?>

 

Why does it rand twice is what Im asking!

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-421848
Share on other sites

your code doesn't make logical sense..

 

IE.. What are you expecting to happen here ?

<?php
unset($_SESSION['rand']);
$pokemonrand2= $_SESSION['rand'];
?>

 

also what makes you think its randomizing twice ?

 

maybe explain what you expecting to happen..

 

Link to comment
https://forums.phpfreaks.com/topic/82857-help-please/#findComment-424158
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.