Shocker88 Posted December 12, 2007 Share Posted December 12, 2007 So i'm trying to setup a cron file and being a cron newbie (php/sql as well), I don't know what is needed to update each users account individually. ie. It takes the first user in the databases values and transfers them down to all users regardless of what values they should have. The script sets back most variables to 0, but it gives back users $hitpoints = to their $maxhp, $energy = to their $energymax and gives $10 000 cash when exectuted. However instead of doing this individually coz each users, it determines the value for the first user in the database and sets that as the variable for all other users. <?php include('conf.php'); //Connection to SQL $connection = @mysql_connect($host, $user, $pass) or die ('Unable to connect!'); mysql_select_db($db); $username = $_SESSION['username']; // Arrays list $query = "SELECT * FROM users"; $result = mysql_query($query); $array = mysql_fetch_array($result); //Set hitpoints and cash values. $hitpoints = $array['maxhp']; $cash = $array['cash'] + 10000; //Save to DB. $query = "UPDATE users SET hitpoints = '$hitpoints', cash = '$cash'"; $result = mysql_query($query); // Gym Arrays $query1 = "SELECT * FROM gym"; $result1 = mysql_query($query1); $array1 = mysql_fetch_array($result1); $energy = $array1['energymax']; $warmcount = 0; $energyused = 0; $totalwarm = 0; $totalmodgym = 0; $query = "UPDATE gym SET energy = '$energy', warmcount = '$warmcount', energyused = '$energyused', totalwarm = '$totalwarm', totalmodgym = '$totalmodgym'"; $result = mysql_query($query); ?> Any help would be much appreciated, thanks. 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.