ryanhami
07-06-2011, 03:04 PM
Hello,
I am currently making a script for a bit of fun and have got stuck at a certain point. My script is a date thing that works with php and mysql. It runs by a cron job that I have setup. Below you can see the two different files. In the table in the mysql database, there are just 3 fields. Day, Month and Year.
Cron Job File
<?
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'];
?>
<?
$date = gamedate($day, $month, $year)
?>
<?
mysql_query($date);
?>
Function File
<? function gamedate($day, $month, $year) {
if ($day == "31") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "12" && $day == "31") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = 1 AND SET Year = Year + 1"));
} elseif ($month == "2" && $day == "28") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "4" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "6" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "9" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "11" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} else {
return ($date = ("UPDATE Date SET Day = Day + 1"));
}
}
?>
I am currently running the cron every minute to test it but it gets stuck at 31/1/2000
It should change to 1/2/2000 but it does not seem to want to do it and I cannot see anything wrong with it.
Any help would be much appreciated.
Thanks,
Ryan
I am currently making a script for a bit of fun and have got stuck at a certain point. My script is a date thing that works with php and mysql. It runs by a cron job that I have setup. Below you can see the two different files. In the table in the mysql database, there are just 3 fields. Day, Month and Year.
Cron Job File
<?
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'];
?>
<?
$date = gamedate($day, $month, $year)
?>
<?
mysql_query($date);
?>
Function File
<? function gamedate($day, $month, $year) {
if ($day == "31") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "12" && $day == "31") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = 1 AND SET Year = Year + 1"));
} elseif ($month == "2" && $day == "28") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "4" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "6" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "9" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} elseif ($month == "11" && $day == "30") {
return ($date = ("UPDATE Date SET Day = 1 AND SET Month = Month + 1"));
} else {
return ($date = ("UPDATE Date SET Day = Day + 1"));
}
}
?>
I am currently running the cron every minute to test it but it gets stuck at 31/1/2000
It should change to 1/2/2000 but it does not seem to want to do it and I cannot see anything wrong with it.
Any help would be much appreciated.
Thanks,
Ryan