Can anyone see a problem with this script?? <?php include "globals.php"; { $price=($ir['hp']); $chest=($ir['maxhp']); $main=($chest - $price); } if($fm < $main) { echo "You can't afford to heal yourself"; } else { $db->query("UPDATE users SET money=money-$main WHERE userid=$userid"); $query4="UPDATE users SET hp=maxhp WHERE hp>maxhp"; $db->query($query4); print "You healed yourself"; } ?> PHP: cos when i run this script, when $fm is greater than $main it still shows the you cant afford to be healed. anyone know why??
{ $price=($ir['hp']); $chest=($ir['maxhp']); $main=($chest - $price); } PHP: I wonder what are the brackets for here?
if you can run it the brackets may not affect anything your if conditions should not fail you why don't you put echo $fm and echo $main before the if condition to see if the variables has changed in the process
i think ive found the problem, the $fm variable has a $ sign infront of the numbers, so could this be affecting it, when the $fm is displayed in an echo command it shows '$10000' cos its a currency variable, could that $ sign be affecting it
how can i read from the database with this code SELECT * FROM `users` WHERE 1`money` and make the money field a variable??
You could learn PHP and SQL by the time you break down all your codes and ask about all of them. I answered your similar post in another thread.
You can probably check the other two threads of yours where I gave you some code which you can use to get both of these issues solved