Shiny_Charizard Posted January 19, 2008 Share Posted January 19, 2008 <?PHP session_start(); include('connect.php'); //Slot 1 Variables $slot1_2= mysql_query("SELECT * FROM pokemon WHERE username='$_SESSION[username]' AND slot='1'"); $slot1= mysql_fetch_array($slot1_2); if(isset($_POST['submit'])) { $c_exp = $slot1['pkmn_exp2']; $a_exp = rand(10,20); $exp = $c_exp + $a_exp; $update_exp1 = "UPDATE pokemon SET pkmn_exp2='$exp' WHERE username='$_SESSION[username]' AND slot='1'"; echo "Your $slot1[pkmn_name] gained <b>$exp</b> experience!"; //If pokemon gains level if($slot1['pkmn_exp2'] == $slot1['pkmn_exp']) { $g_exp = rand(15,25); $o_exp = $slot['pkmn_exp']; $new_exp = $g_exp + $o_exp; $g_level = 1; $o_level = $slot1['pkmn_level']; $n_level = $g_level + $o_level; $updatelvl="UPDATE * pokemon SET pkmn_level='$n_level' WHERE slot='1' AND username='$_SESSION[username]'"; $update_exp="UPDATE * pokemon SET pkmn_exp='$new_exp' WHERE slot='1' AND username='$SESSION[username]'"; echo"Your $slot1[pkmn_name] gained <b>1</b> level!"; } } echo "<center> <form action='gainexp.php' method='POST'> Do you want your Pokémon to gain experience? <br /> Click the button below to gain some. <br /> <input type='submit' name='submit' value='Gain Exp'> </br /> </form> </center>"; ?> For some reason it doesn't update the MySQL rows. Can anybody please help me figure out what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/86738-solved-what-is-wrong-with-my-code/ Share on other sites More sharing options...
revraz Posted January 19, 2008 Share Posted January 19, 2008 What are you trying to do with UPDATE * Quote Link to comment https://forums.phpfreaks.com/topic/86738-solved-what-is-wrong-with-my-code/#findComment-443278 Share on other sites More sharing options...
revraz Posted January 19, 2008 Share Posted January 19, 2008 Also, you are not even running a mysql_query command on any of your update variables. Quote Link to comment https://forums.phpfreaks.com/topic/86738-solved-what-is-wrong-with-my-code/#findComment-443279 Share on other sites More sharing options...
mmarif4u Posted January 19, 2008 Share Posted January 19, 2008 Change this: $updatelvl="UPDATE * pokemon SET pkmn_level='$n_level' WHERE slot='1' AND username='$_SESSION[username]'"; $update_exp="UPDATE * pokemon SET pkmn_exp='$new_exp' WHERE slot='1' AND username='$SESSION[username]'" to this: $updatelvl=mysql_query("UPDATE pokemon SET pkmn_level='$n_level' WHERE slot='1' AND username='$_SESSION[username]'"); $update_exp=mysql_query("UPDATE pokemon SET pkmn_exp='$new_exp' WHERE slot='1' AND username='$SESSION[username]'"); and let us know. Quote Link to comment https://forums.phpfreaks.com/topic/86738-solved-what-is-wrong-with-my-code/#findComment-443282 Share on other sites More sharing options...
Shiny_Charizard Posted January 19, 2008 Author Share Posted January 19, 2008 It works thanks a lot guys. Quote Link to comment https://forums.phpfreaks.com/topic/86738-solved-what-is-wrong-with-my-code/#findComment-443283 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.