Hello. I am currently making a php game for a bit of fun but I have got stuck at one point. I am trying to create a cron job that runs a function which updates the database. Below I have posted bits of the code. Function function aircraftdelivery($day, $month, $year, $delivery_day, $delivery_month, $delivery_year) { if ($day == "$delivery_day" && $month == "$delivery_month" && $year == "$delivery_year") { return ($delivered = ("UPDATE Aircraft SET Delivered = 'Yes' WHERE Delivery_Day = '" . $day . "'")); } } PHP: Cron Job <? include("include/db.php"); include("include/config.php"); include("include/functions.php"); ?> <? $query = ("SELECT * FROM Date"); $row = (mysql_fetch_array(mysql_query($query))); $day = $row['Day']; $month = $row['Month']; $year = $row['Year']; $query2 = ("SELECT * FROM Aircraft"); $row2 = (mysql_fetch_array(mysql_query($query2))); $delivery_day = $row2['Delivery_Day']; $delivery_month = $row2['Delivery_Month']; $delivery_year = $row2['Delivery_Year']; ?> <? $date = gamedate($day, $month, $year); $delivered = aircraftdelivery($day, $month, $year, $delivery_day, $delivery_month, $delivery_year); ?> <? mysql_query($date); mysql_query($delivered); ?> PHP: The $date mysql query updates the date in the database every minute and its stored by day, month and year. The $delivered query is trying to update a field in another table if the date of the game is the same as that in the table where the other field is. It is not working for some reason. It works if you enter the random numbers into the variables rather than getting them from the database. I am wondering if its missing the date. But not sure. Any help would be much appreciated. Ryan
Hy, Try add the mysql_query($delivered); into the aircraftdelivery() function. Also, make some test (with echo) to see what parameters that function receives.
Thanks for the reply, but that did not work. I have made a crontest.php just to see if I run it by in my browser rather than the cron job it works. But that is without the date query. I need both to be in the same file though.