ok here goes, this is killing me.
this is my attack script.
[CODE=php]function attack(){
global $targetname;
$healthbefore = getValueID("hea lth", "userdata", $_SESSION['id']);
$dmgrand= mt_rand(1,10);
$strength = 10;
$dmg = ($dmgrand * $strength);
$healthafter = ($healthbefore - $dmg);
if ($healthafter < 0){
$healthafter = 0;
}
updateValueUSER ("health", "$healthaft er", "userdata", "$targetnam e");
echo "Health before was $healthbefore. You dealt $dmg damage. $targetname now has $healthafter health left.";
}[/CODE]
here's updateValueUSER :
[CODE=php]function updateValueUSER ($column, $value, $table, $username){
global $conn;
$q = "UPDATE $table SET $column = $value WHERE username = '$username'";
$result = mysql_query($q, $conn);
}[/CODE]
the problem is that it never sets the value of "health" in the database to $healthafter. every time I try to check the health, it's back at 100. anyone have an idea? this is really killing me...
this is my attack script.
[CODE=php]function attack(){
global $targetname;
$healthbefore = getValueID("hea lth", "userdata", $_SESSION['id']);
$dmgrand= mt_rand(1,10);
$strength = 10;
$dmg = ($dmgrand * $strength);
$healthafter = ($healthbefore - $dmg);
if ($healthafter < 0){
$healthafter = 0;
}
updateValueUSER ("health", "$healthaft er", "userdata", "$targetnam e");
echo "Health before was $healthbefore. You dealt $dmg damage. $targetname now has $healthafter health left.";
}[/CODE]
here's updateValueUSER :
[CODE=php]function updateValueUSER ($column, $value, $table, $username){
global $conn;
$q = "UPDATE $table SET $column = $value WHERE username = '$username'";
$result = mysql_query($q, $conn);
}[/CODE]
the problem is that it never sets the value of "health" in the database to $healthafter. every time I try to check the health, it's back at 100. anyone have an idea? this is really killing me...
Comment