Php and cron job php script enquiery

Hi there,

i have a cpanel webhosting account and i have a php script that i need to be ran every 15 minutes now i have set this up in the cronjob control panel area.

This is what i have atm

Minute Hour Day Month Weekday Command Actions
*/15 * * * * php -q /home/willbcco/public_html/facebook/compare2.php Edit Delete

Is that correct i want to have it so it loads the page which and updates the mysql database of every user every 15 minuttes not sure if its doing it based on my end or servers end but atm ive got it so it emails me every 15 minutes but doesnt email me every 15 minutes of every hour so my men should increase by 1 every 15 minutes

am i on the right path here?

Can anyone advise me if i am or not,

Thanks,Willioam

Yes, that’s the right syntax. If it’s not running, then specify the full path to the PHP binary as it may not be in the PATH of the user the cron daemon is running under.

okay kool but some some reason not entirely sure if my calculations is correct my game units get their units increased by one not sure if its a programing error or server area every time the units gets increased in my application im developing all of them only have 7 by now,

So heres my php code not sure why i am getting this problem because if i the cronjob is running every 15 minutes doesnt that mean by this morning all users should have 50 or so units by this time this morning or my time?

Here is my php code


require("functions2.php");
include_once("dbconnect.php");
include("header.inc.php");
$r="SELECT * FROM players";
echo $r;
$rs=mysqli_query($con,$r);
if(!$rs)
{
	echo "Error".mysqli_error($con);
}
else
{
	$count=$rs->num_rows;
	if($count>0)
	{
		//
		while($data=$rs->fetch_assoc())
		{
			//
			$u=$data['user'];
			$ut=$data['Units'];
			echo update($u);	
			//
		}
		//
	}
}

The Update function is this


function update($u)
			{
				include("dbconnect.php");
				$r="update players set units=units+1 WHERE user='$u'";
				echo $r;
				$rs=mysqli_query($con,$r);
				if(!$rs)
				{
					echo "Error".mysqli_error($con);	
				}
				else
				{
					$adminemail="email";
					$email="email";
					mail($email, "New Units", "New units have been added on your facebook game","From: $adminemail");
				}
			}

So why do all my users in my database show up as only showing 7 units when they should have atleast 50 or so?

Thanks,William

  1. Please use sentences. It’s hard to read your writing when it runs from one sentence fragment into the next several times before any punctuation appears.

  2. Did you receive the expected number of e-mails?

  3. Why do you have a loop if you are updating every row in the table? The UPDATE query with no WHERE clause would do it.

UPDATE players SET units = units + 1