[Solved] Passing variable to php cron job.
Posted: Sun Aug 12, 2007 2:28 pm
I'm trying to do something that should be so simple.
I want to pass a variable to a php cron job script.
This is the php script:
This works perfectly if put the 'id' in directly and not pass it. However, trying to pass the data gives the 'Input File not found error'. Now, doing some searching I came across a thread that said you can't pass variables in the tradtional sense. eg $_GET So the syntax was to just use a space.
eg. script.php variable1=value
This worked in the fact that I now get a MySQL error because of not reading the 'id' variable.
So how do you read php variables with a space instead of a question mark into the script?
Heres the cron job command line:
Any help appreciated.
I want to pass a variable to a php cron job script.
This is the php script:
Code: Select all
#!/usr/bin/php
<?php
require('connect.php');
$id = (int)$_GET['id'];
$game_data = mysql_fetch_array(mysql_query("SELECT game_id FROM game_data WHERE week=id"));
$update = "UPDATE results_data SET status='Closed' WHERE results_id=$game_data[0]";
$update_info = mysql_query($update) or die ('Database Error: ' . mysql_error());
echo "Cron Job ran Successfully";
?>eg. script.php variable1=value
This worked in the fact that I now get a MySQL error because of not reading the 'id' variable.
So how do you read php variables with a space instead of a question mark into the script?
Heres the cron job command line:
Code: Select all
php -q /home/mysite/public_html/cron/update_cron_22.php id=22