开发者

Deleting records from the server after 15 days

I need to delete uploaded files from the server after 15 days using SQL.

How would I do that? The following is the current code, but it isn't working.

<?php
$con = mysql_connect("localhost","mt","mt");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mt", $con);

function curdate(){
date_default_timezone_set开发者_运维问答 ("Asia/Calcutta"); 
$cd=date("d/m/Y");
}

mysql_query("DELETE FROM mt_upload WHERE DateTime < DATE_SUB(curdate(), INTERVAL 1 DAY)
'");

mysql_close($con);
?> 


I believe there may be a date / datetime mismatch in your statement which I've seen act goofy under MySQL. Try to match date comparison with dates and datetime comparisons with datetime.

Try using now() instead of curdate() and see if you get better behavior.

"DELETE FROM mt_upload WHERE DateTime < DATE_SUB(now(), INTERVAL 15 DAY)"


You have to configure cron jobs for that........

you have cron Job in your cpanel setup that.......

configure the timestamps,

set the php file with only delete script no timestamp management.........

may be you can search for CRon job over google......

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜