简体   繁体   中英

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.

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...

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()');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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