i keep getting this error Parse error: syntax error, unexpected $end in /public_html/test2.php on line 16 whats up with this code?? <?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"); $query3="UPDATE users SET hp=hp+(maxhp/3) WHERE hp<maxhp"; $query4="UPDATE users SET hp=maxhp WHERE hp>maxhp"; $db->query($query3); $db->query($query4); print "You healed yourself"; ?> PHP: dont worry about the variable $fm thats being called in from globals.php
You have an open brace '{' on line 2 but no closing brace. You probably also want to put braces '{}' around the lines after the else, otherwise it will just execute the first line as the else and the rest will always be executed.
Replace your code with <?php include "globals.php"; $main= $ir['maxhp'] - $ir['hp']; if($fm < $main){ echo "You can't afford to heal yourself"; } else { $db->query("UPDATE `users` SET money=money-".$main." WHERE userid=".$userid); $db->query("UPDATE `users` SET hp=hp+(maxhp/3) WHERE hp<maxhp"); $db->query("UPDATE `users` SET hp=maxhp WHERE hp>maxhp"); echo "You healed yourself"; } ?> Code (markup): and it should work I assume $userid is also available from globals.php