Ryuujin Posted May 17, 2008 Share Posted May 17, 2008 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 More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 for crontab, you typically have to call php explicitly, like: 0,15,30,45 * * * * /usr/bin/php /home2/myboxir8/public_html/moneycron.php Link to comment https://forums.phpfreaks.com/topic/106054-solved-php-scripts-amp-cron-jobs/#findComment-543569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.