简体   繁体   English

PHP MYsql 使用时间戳比较删除语法的问题

[英]Problem with PHP MYsql Delete syntax with timestamp comparison

All I am trying to do is delete rows in a column that have a timestamp more than 2 days old.我要做的就是删除时间戳超过 2 天的列中的行。

I have tried a lot of things I have seen on here, but none of them seem to be working.我已经尝试了很多我在这里看到的东西,但它们似乎都没有工作。

This is the code:这是代码:

$delquery = $tapeDB->query('DELETE FROM newsItems WHERE news_date < TIMESTAMPADD(DAY,-2,NOW());

These are the errors I am getting on that line:这些是我在那条线上遇到的错误:

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in... Parse error: syntax error, unexpected T_STRING in...警告:输入中的意外字符:''' (ASCII=39) state=1 in... 解析错误:语法错误,意外的 T_STRING 在...

This should be really easy but I can't figure out what I am doing wrong.这应该很容易,但我无法弄清楚我做错了什么。

you forgot the closing quote你忘记了结束语

$delquery = $tapeDB->query('DELETE FROM newsItems WHERE news_date < TIMESTAMPADD(DAY,-2,NOW()');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM