douzhuan1432 2016-11-27 23:08
浏览 22
已采纳

为什么在间隔函数上设置的My MYSQLI DELETE未运行

I have search and tried all codes I could find to try to delete certain rows based on an 8hr interval from current time but it is not working. I put it in the header and in other pages. here is my code:

`date_default_timezone_set('Country/City');
if (isset($_SESSION["login"])) {
    $display = $_SESSION["login"];
    $day_nudge = mysqli_query($conn,"DELETE FROM nudges WHERE nudge_time < DATE_ADD(NOW(), INTERVAL -8 HOUR)");
}`

I have also tried other ways such as:

DELETE FROM nudges
WHERE nudge_time < (NOW() - INTERVAL 8 HOUR)

DELETE FROM nudges
WHERE nudge_time < DATE_SUB(NOW(), INTERVAL 8 HOUR)

these all worked on local host but now its on my server it does not execute.

  • 写回答

1条回答 默认 最新

  • dongnan4571 2016-12-01 14:14
    关注

    After taking a break and playing with some other bugs... I came back and just thought I would try something and it worked for me, thought I would post it here incase anyone else may find it useful.

    $datnudge = date('Y-m-d H:i:s', strtotime('-8 hour'));
    $day_nudge = mysqli_query($conn,"DELETE FROM nudges WHERE nudge_time <= '$datnudge'");   

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入