Jump to content

[SOLVED] PHP Scripts & Cron Jobs


Ryuujin

Recommended Posts

I am creating a game and I am wanting to run a script which updates the users money. Here is the script:

<?php

$con = mysql_connect("localhost","myboxir8_admin","*******");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("myboxir8_unknown", $con);

$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_array($result))
{
	$income = $row['citizens'] * $row['honor'] * 1.2;
	$money = $row['money'];
	$new_money = $money + $income;
	mysql_query("UPDATE users SET money = '$new_money'");
}
?>

 

Now my cron job is:

0,15,30,45 * * * * /home2/myboxir8/public_html/moneycron.php

And I get this error:

/home2/myboxir8/public_html/moneycron.php: line 1: ?php: No such file or directory

/home2/myboxir8/public_html/moneycron.php: line 3: syntax error near unexpected token `('

/home2/myboxir8/public_html/moneycron.php: line 3: `$con = mysql_connect("localhost","myboxir8_admin","*****");'

 

Any help? I'm new to cron jobs, and new to creating PHP games. :-\

 

Thanks,

-Ryu

Link to comment
https://forums.phpfreaks.com/topic/106054-solved-php-scripts-amp-cron-jobs/
Share on other sites

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.