Jump to content

Cron problems - Same values applied to all Users


Shocker88

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.