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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

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.