stylish stylish - 5 months ago 24
MySQL Question

automaticall updating the records every day

I am using this code

$q = mysql_query("SELECT `time` from `table`");
$row = mysql_fetch_assoc($q);
$timeDiff = time() - $row['time'];
if ($timeDiff >= 86400){
//run code

but I am getting an error in in the second line can someone plz help me with this


Here you go:

$datetime = new DateTime("+1 days");
$date = $datetime->format("Y-m-d H:i:s");

$timeDiff = time() - $row['time'];

if($timeDiff >= '$date) {

 //Code Here



You can update your code in your_file.php and run this:

0 0 1 * * php /var/www/vhosts/

This will run once a month, on the first day of the month at midnight (i.e. January 1st 12:00am, February 1st 12:00am etc.):

For further explanation:


Hope it will help you.