Forum Moderators: open
At first I was trying to insert in the current date, so I used:
mysql_query("INSERT INTO table (date) VALUES (CURDATE())");
That worked fine. But then I needed to insert in yesterday's date. That didn't work so well (resulting error: "syntax error, unexpected T_STRING ").
mysql_query("INSERT INTO table (date) VALUES (DATE_SUB(CURDATE(),INTERVAL 1 DAY))");
Any ideas?
table(and
date) is a reserved word [dev.mysql.com]. You should avoid using reserved words for table and column names otherwise you will need to employ special syntax when using them in query statements. In this case, if you put them both in backticks you should overcome your syntax error.