ok if i do it that way then it will only make all players energys to 1 set amount every hour, im wanting to add 1 point to the total of there energy and if they have 24 points in there energy field to not add anything.
sorry that im not getting this.
ok so i got this what i got so far, and it will update all the users to the same amount but not add 1 it just sets everyones to 3. so would i need to use WHILE() and Rows? becuz i had that same ''Resource id #2'' when i was trying to display the user name and stats.
Quote:
<?
$host="localhost";//hostname
$username="";//username
$password="";//datebase password
$db_name="";//datebase name
//function addEnergy()
//connect to database
mysql_connect("$host","$username","$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");
$test=yes;
if($test==yes)
{
$string = 'SELECT energy FROM users';
$currentEnergy = mysql_query($string);
$addedEnergy = $currentEnergy + 1;
$string2 = 'UPDATE users SET energy = \'' . $addedEnergy . '\'';
$addEnergy = mysql_query($string2);
echo $string.'$string=<br/>';
echo $currentEnergy.'$currentEnergy=<br/>';
echo $addedEnergy.'$addedEnergy=<br/>';
echo $string2.'$string2<br/>';
echo $addEnergy.'$addEnergy<br/>';
}
else
{echo'fail';}
?>
|
Last edited by xwhitchx; 06-26-2010 at 07:23 PM..
|