Xyphon Posted December 16, 2007 Share Posted December 16, 2007 <?PHP //Include Connection File include("Connect.php"); //Include Top File include("top.php"); //Define User Variables $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; } //Define Variables $Submit= $_POST['Submit']; $PokemonName="GoldenGroudon"; $Attack= rand(32, 36); $Defence= rand(31, 37); $Image="http://i8.tinypic.com/6sv817m.jpg"; $Icon="http://i15.tinypic.com/7289340.jpg"; $Level= rand(5, 15); $EXP= 0; $NEXP= rand(20, 30); $Attack1="Flamethrower"; $Attack2="Hydro Pump"; $Attack3="Razor Leaf"; $Attack4="Thunder"; //Find User Result $Result1= mysql_query("SELECT * FROM users WHERE ID='$ID'"); $Rows1= mysql_fetch_array($Result1); //Define User Variables $PromoGot= $Rows1['Promo']; //Display Promo echo "<img src='$Image'><br />"; //If Promotional Pokémon Is Obtained if($PromoGot=="Yes") { //Display Message echo "Sorry, you have already obtained the Promo."; //Include Bottom File include("bottom.php"); //Exit Page exit; } //Define Random Variables $PromoRand= rand(1, 19); //If Gender Is Male if($PromoRand < 10 && $PromoRand > 0) { //Define Promo Variables $PromoGender="Male"; } //If Gender Is Female elseif($PromoRand < 19 && $PromoRand > 10) { //Define Promo Variables $PromoGender="Female"; } //If Promo Is Ungendered else { //Define Promo Variables $PromoGender="Ungendered"; } //Find Pokémon $Result2= mysql_query("SELECT * FROM pokemon_info WHERE user_id='$ID'"); $Rows2= mysql_fetch_array($Result2); //If User Has No Pokémon if(empty($Rows2)) { //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 Form Is Not Submitted if(!$Submit) { //Display Form echo "<form method='POST'> <input type='hidden' name='Submit' value='1'> The current Promo is $PokemonName.<br /><br /> <input type='submit' value='Obtain Promo' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </form>"; } //If Form Is Submitted else { $PromoGot='Yes'; //Insert Data mysql_query("INSERT INTO users (Promo) VALUES ('$PromoGot')"); mysql_query("INSERT INTO pokemon_info (user_id, pokemon_name, pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon, pokemon_level, pokemon_exp, nexp, attack1, attack2, attack3, attack4, pokemon_slot) VALUES ('$ID', '$PokemonName', '$Attack', '$Defence', '$Image', '$PromoGender', '$Icon', '$Level', '$EXP', '$NEXP', '$Attack1', '$Attack2', '$Attack3', '$Attack4', '$AP_Slot')"); //Display Message echo "You have obtained $PokemonName."; } //Include Bottom File include("bottom.php"); ?> It wont change promo to yes, and it wont insert pokemon data.. why? Link to comment https://forums.phpfreaks.com/topic/81954-solved-why-wont-it-insert-info/ Share on other sites More sharing options...
pocobueno1388 Posted December 16, 2007 Share Posted December 16, 2007 It would help if you added a mysql_error catch to the queries like this <?php mysql_query("INSERT INTO users (Promo) VALUES ('$PromoGot')")or die(mysql_error()); mysql_query("INSERT INTO pokemon_info (user_id, pokemon_name, pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon, pokemon_level, pokemon_exp, nexp, attack1, attack2, attack3, attack4, pokemon_slot) VALUES ('$ID', '$PokemonName', '$Attack', '$Defence', '$Image', '$PromoGender', '$Icon', '$Level', '$EXP', '$NEXP', '$Attack1', '$Attack2', '$Attack3', '$Attack4', '$AP_Slot')")or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/81954-solved-why-wont-it-insert-info/#findComment-416377 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Thanks, its fixed. Link to comment https://forums.phpfreaks.com/topic/81954-solved-why-wont-it-insert-info/#findComment-416395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.