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? Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/ 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. Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707112 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... Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707116 Share on other sites More sharing options...
Xyphon Posted December 5, 2008 Author Share Posted December 5, 2008 Yeah sorry about that. Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707119 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); Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707167 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. Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707183 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? Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707188 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. Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707190 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? Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707191 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. Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707223 Share on other sites More sharing options...
Xyphon Posted December 6, 2008 Author Share Posted December 6, 2008 Bump Link to comment https://forums.phpfreaks.com/topic/135711-occasional-problems/#findComment-707807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.