joecooper Posted October 29, 2013 Share Posted October 29, 2013 $newtime = date("Y-m-d H:i:s", time() + 600); mysql_query("UPDATE rounds SET clock = $newtime WHERE `round`='$CurrentRound' ") or die(mysql_error()); //update DB This code is failing to add the current time (+10 mins) to the MySQL database. The cell in the database is datetime format. I had done this before, but upon rewriting the code, it has stopped working. Link to comment https://forums.phpfreaks.com/topic/283417-mysql-datetime-insert/ Share on other sites More sharing options...
mac_gyver Posted October 29, 2013 Share Posted October 29, 2013 date/time values in a query statement are literal strings and must be enclosed by single-quotes. without single quotes, 2013-10-29 is a mathematical subtraction problem (i.e. 1974.) Link to comment https://forums.phpfreaks.com/topic/283417-mysql-datetime-insert/#findComment-1456123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.