Jump to content

Occasional problems


Xyphon

Recommended Posts

//Find Rows

$Result2= mysql_query("SELECT * FROM users WHERE ID='$ID'");

$Rows2= mysql_fetch_array($Result2);

 

//Define User Variables

$Pokémon= $Rows2['VolcanoValley'];

$Pokémon2= $Rows2['VolcanoValley2'];

//If Action Is Not Null

if($Action=="catch")

{

  //If Form Is Not Submitted

if(!$Submit)

{

 

    //Define Random Variables

    $PokémonRand= rand(1, 100);

 

    //If Pokémon Is Charmander

    if($PokémonRand >= 1 && $PokémonRand <= 25)

    {

      //Define Pokémon Variables

      $PokémonNumber= 1;

      $PokémonName="Charmander";

      $PokémonImage="http://i13.tinypic.com/6xvsvw7.png";

    }

 

    //If Pokémon Is Magby

    elseif($PokémonRand >= 26 && $PokémonRand <= 50)

    {

      //Define Pokémon Variables

      $PokémonNumber= 2;

      $PokémonName="Magby";

      $PokémonImage="http://i10.tinypic.com/8also6f.png";

    }

 

    //If Pokémon Is Numel

    elseif($PokémonRand >= 51 && $PokémonRand <= 75)

    {

      //Define Pokémon Variables

      $PokémonNumber= 3;

      $PokémonName="Numel";

      $PokémonImage="http://i5.tinypic.com/73e7me8.png";

    }

 

    //If Pokémon Is Nothing

    elseif($PokémonRand >= 76 && $PokémonRand <= 99)

    {

      //Define Pokémon Variables

      $PokémonNumber= 0;

      $PokémonName="Nothing";

      $PokémonImage="";

    }

 

    //If Pokémon Is Entei

    else

    {

      //Define Pokémon Variables

      $PokémonNumber= 4;

      $PokémonName="Entei";

      $PokémonImage="http://i8.tinypic.com/7xxnyud.png";

    }

 

    //If Pokémon Is Nothing

    if($PokémonName=="Nothing")

    {

      //Display Message

      echo "You have found nothing when searching for Pokémon.<br /><br />

 

      <a href='map1.php?action=catch'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";

    }

 

    //If Pokémon Is Not Nothing

    else

    {

      //Define Random Variables

      $PokémonRand2= rand(1, 49);

 

      //If Gender Is Male

      if($PokémonRand2 >= 1 && $PokémonRand2  <= 24)

      {

        //Define Gender Variables

        $PokémonGender="Male";

        $PokémonGSign="(M)";

      }

 

      //If Gender Is Female

      elseif($PokémonRand2 >= 25 && $PokémonRand2  <= 48)

      {

        //Define Gender Variables

        $PokémonGender="Female";

        $PokémonGSign="(F)";

      }

 

      //If Gender Is Ungendered

      elseif($PokémonRand2== 49)

      {

        //Define Gender Variables

        $PokémonGender="Ungendered";

        $PokémonGSign="(U)";

      }

 

      //If Gender Is Unknown

      else

      {

        //Define Gender Variables

        $PokémonGender="Male";

        $PokémonGSign="(M)";

      }

 

      //Update Information

      mysql_query("UPDATE users SET VolcanoValley='$PokémonNumber', VolcanoValley2='$PokémonGSign' WHERE ID='$ID'");

      //Define User Variables

 

      //Display Form

      echo "

 

      <form action='?action=catch' method='POST'>

      <input type='hidden' name='Submit' value=1'>

      <img src='$PokémonImage' alt='$PokémonName' title='$PokémonName'><br />

      <b>$PokémonName</b><br /><br />

 

      You have encountered a wild $PokémonName <b>$PokémonGSign</b>!<br /><br />

 

      <input type='submit' value='Catch $PokémonName' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"><br /><br />

      </form>";

 

      echo "<a href='map1.php?action=catch'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";

    }

  }

 

 

Okay, so basically this is a snipit of the script, and where I believe everything is going wrong. When I click on the map, let's say I get a female Numel, it should make Volcano Valley='3' int he database and Volcano Valley 2='(F)' but about 50-75% of the time it randomizes it. Why is this?

Link to comment
Share on other sites

in code:

<?php //Find Rows
$Result2= mysql_query("SELECT * FROM users WHERE ID='$ID'");
$Rows2= mysql_fetch_array($Result2);

//Define User Variables
$Pokémon= $Rows2['VolcanoValley'];
$Pokémon2= $Rows2['VolcanoValley2'];
//If Action Is Not Null
if($Action=="catch")
{
  //If Form Is Not Submitted
if(!$Submit)
{

    //Define Random Variables
    $PokémonRand= rand(1, 100);

    //If Pokémon Is Charmander
    if($PokémonRand >= 1 && $PokémonRand <= 25)
    {
      //Define Pokémon Variables
      $PokémonNumber= 1;
      $PokémonName="Charmander";
      $PokémonImage="http://i13.tinypic.com/6xvsvw7.png";
    }

    //If Pokémon Is Magby
    elseif($PokémonRand >= 26 && $PokémonRand <= 50)
    {
      //Define Pokémon Variables
      $PokémonNumber= 2;
      $PokémonName="Magby";
      $PokémonImage="http://i10.tinypic.com/8also6f.png";
    }

    //If Pokémon Is Numel
    elseif($PokémonRand >= 51 && $PokémonRand <= 75)
    {
      //Define Pokémon Variables
      $PokémonNumber= 3;
      $PokémonName="Numel";
      $PokémonImage="http://i5.tinypic.com/73e7me8.png";
    }

    //If Pokémon Is Nothing
    elseif($PokémonRand >= 76 && $PokémonRand <= 99)
    {
      //Define Pokémon Variables
      $PokémonNumber= 0;
      $PokémonName="Nothing";
      $PokémonImage="";
    }

    //If Pokémon Is Entei
    else
    {
      //Define Pokémon Variables
      $PokémonNumber= 4;
      $PokémonName="Entei";
      $PokémonImage="http://i8.tinypic.com/7xxnyud.png";
    }

    //If Pokémon Is Nothing
    if($PokémonName=="Nothing")
    {
      //Display Message
      echo "You have found nothing when searching for Pokémon.<br /><br />

      <a href='map1.php?action=catch'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
    }

    //If Pokémon Is Not Nothing
    else
    {
      //Define Random Variables
      $PokémonRand2= rand(1, 49);

      //If Gender Is Male
      if($PokémonRand2 >= 1 && $PokémonRand2  <= 24)
      {
        //Define Gender Variables
        $PokémonGender="Male";
        $PokémonGSign="(M)";
      }

      //If Gender Is Female
      elseif($PokémonRand2 >= 25 && $PokémonRand2  <= 48)
      {
        //Define Gender Variables
        $PokémonGender="Female";
        $PokémonGSign="(F)";
      }

      //If Gender Is Ungendered
      elseif($PokémonRand2== 49)
      {
        //Define Gender Variables
        $PokémonGender="Ungendered";
        $PokémonGSign="(U)";
      }

      //If Gender Is Unknown
      else
      {
        //Define Gender Variables
        $PokémonGender="Male";
        $PokémonGSign="(M)";
      }

      //Update Information
      mysql_query("UPDATE users SET VolcanoValley='$PokémonNumber', VolcanoValley2='$PokémonGSign' WHERE ID='$ID'");
      //Define User Variables

      //Display Form
      echo "

      <form action='?action=catch' method='POST'>
      <input type='hidden' name='Submit' value=1'>
      <img src='$PokémonImage' alt='$PokémonName' title='$PokémonName'><br />
      <b>$PokémonName</b><br /><br />

      You have encountered a wild $PokémonName <b>$PokémonGSign</b>!<br /><br />

      <input type='submit' value='Catch $PokémonName' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"><br /><br />
      </form>";

      echo "<a href='map1.php?action=catch'><img border='0' src='http://i13.tinypic.com/8104aqe.jpg'></a>";
    }
  }
?>

just to help me...

Link to comment
Share on other sites

actually, those questions may sound stupid. so, when you go to the page and action=catch you are supposed to get one of 3 or 4 pokemon or non at all. right?

if you did catch a pokemon it changes the the user to have that pokemon for that location or whatever. right?

Link to comment
Share on other sites

Okay, when the pokemon pops up it asks if you want to catch it. So, it displays the pokemon and adds information to the database so the database knows what pokemon it is before you catch it (because it would re-rand after making a new page, so instead I use the database to pick it up) but for some reason it displays the right pokemon, but adds the WRONG pokemon to the database about 50% of the time.

Link to comment
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.