DreamCoder Posted June 4, 2011 Share Posted June 4, 2011 Ok im not sure if im doing this correctly but i need some help here dominion says im on the right track <?php require('config.php'); $health == 100; if ($health < 99) { mysql_query("UPDATE `health` SET 'health' = 100 WHERE 'health <99'"); } $user = mysql_fetch_array(mysql_query("SELECT `lastHP_Time` FROM `members` WHERE `userid`=". $_SESSION['session_name_here'])); //timestamp here ?> what im trying to do is when the players health goes below 99 it will start going back up like mccodes but i cant seem to get it right Quote Link to comment Share on other sites More sharing options...
Analog Posted June 4, 2011 Share Posted June 4, 2011 First thing I see is your setting $health to = 100 prior to the if statement. With that being said, your if statement is always going to return false.... Quote Link to comment Share on other sites More sharing options...
Djkanna Posted June 4, 2011 Share Posted June 4, 2011 mysql_query('UPDATE `health` SET `health` = `health` + 1 WHERE (`health` < 100)'); Would go up 1 each time health is below 100, but I worry, how is this now user specific? And why is there a table devoted to health? Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 4, 2011 Share Posted June 4, 2011 (edited) I thought health was going to be in a stats table? “$health == 100; “ (should only have one = btw way) is where a database query goes to check the users health as it stands. Edited June 4, 2011 by Dominion Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted June 4, 2011 Share Posted June 4, 2011 You have said $health == 100; Therefore $health is ALWAYS going to be 100 no matter who runs the file. You have to make it user specific by using a WHERE statement in the mysql query, or using selecting the 'health' value from the db for the user. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.