Jump to content

[SOLVED] What is wrong with my code?


Shiny_Charizard

Recommended Posts

<?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?

Link to comment
Share on other sites

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.

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.