Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

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....

Posted

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?

Posted (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 by Dominion
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...