problem with math and adding numbers to database

so this is my attack code, it looks like it works but no matter how much damage you do it will kill the other player. so if i do 0 dmg to some one with 10 hp it was say i did 0 and i have it echo out how much hp they still has. that all works fine but when i go to the next page all there hp is gone…. i dont understand y it is doing this.

PHP Code:


if ($_GET['att']=='Attack')
{
$att=ceil($user1luk*$user1dex*$user1str/4+$user1int/4+3);
$defend=ceil($user2luk*$user2dex+$user2int/3);
$outcome=ceil($att-$defend);
//-----------------------------------------
 
$attdamagemysql_query("SELECT * FROM users WHERE username='$getusername'");
while(
$row3 mysql_fetch_array($attdamage))
  {
  
$user2hp$row3['hp'];
 
 
  if (
$outcome<0)
  {
  
$outcome=0;
  }
 
  else{
    
$outcome=$outcome;
  }
 
 
  
$user2suphp$user2hp $outcome;
 
 
 
 
  
$newhpmysql_query('UPDATE users SET hp= "\''.$user2suphp.'\'" WHERE username=\''.$row3['username'].'\'');
 
 }
 
 
 
//text-----------------------
if($user2suphp==|| $user2suphp>0)
 {
 echo
'You did '.$outcome.' Damage to '.$getusername.'<br/>';
 echo  
$outcome.'<br/>';
 echo 
$user2suphp.'<br/>';
 echo 
$newhp.'<br/>';
 
 }
 else
 {
 
  echo
'You did '.$outcome.' Damage to '.$getusername;
 echo
'you have killed '.$getusername.'<br/>';
 
 
 } 




View full post on Webmaster-Talk.com

, , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved