我将以下 php 代码设置为作为 CRON 作业运行。它每天运行一次并且从不返回错误,所以我认为它运行正常。问题是,这些行没有从我的数据库中删除!
我已经测试了 php 并且变量工作。我已经测试了我的查询并且它也有效,所以我很茫然......
<?php
$isCLI = ( php_sapi_name() == 'cgi-fcgi' );
if (!$isCLI)
die("cannot run! sapi_name is ".php_sapi_name());
exit;
//Connect to DB
mysql_connect("xxxxxx.com", "xxxxxxxxxx", "xxxxxxxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxxxxxx") or die(mysql_error());
//Get today's date
$todayis = date("Y-m-d");
$todayis = strtotime(date("Y-m-d", strtotime($todayis)) . " -4 hours");
$todayis = date('Y-m-d', $todayis);
//Delete rows in userContests where reminder is less than or equal to today's date
mysql_query("DELETE FROM userContests WHERE reminder <= '$todayis';") or die(mysql_error());
?>
有人可以向我解释为什么这些行不会删除吗?