Xyphon Posted December 5, 2008 Share Posted December 5, 2008 //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? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Author Share Posted December 5, 2008 Sorry guys forgot to put in in php things. Wont let me edit. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 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... Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Author Share Posted December 5, 2008 Yeah sorry about that. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted December 5, 2008 Share Posted December 5, 2008 Err, isn't it randomized because you made it so? $PokémonRand2= rand(1, 49); Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Author Share Posted December 5, 2008 Noo, not like that. This is what happens, it'll display this: Charmander (M) appeared, or something. But it'll put it in the database differently. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 let me ask a question... are you trying to pull a random pokemon (lol, i hate pokemon) based on the location? or are you trying to get a specific pokemon? Quote Link to comment Share on other sites More sharing options...
waynew Posted December 5, 2008 Share Posted December 5, 2008 Hm. Why not get your database to cache them all? *Sorry.... reeeally bad joke. Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 5, 2008 Share Posted December 5, 2008 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? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Author Share Posted December 5, 2008 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. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 6, 2008 Author Share Posted December 6, 2008 Bump 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.