I am running a mysql query in my php strict where I have to insert the current date in a column, but when running, I am confronted with this error:
Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '22:42:06 WHERE RequestorID = 1 AND RequesteeID = 5 AND StoryID = 16' at line 1
Here is the part of my code that is causing this issue:
$usrID = 5;
//The user that accepts
$rqstorID = 1;
//This requestor
$stryID = 16;
//The story ID
date_default_timezone_set('Asia/Beirut');
$date = date('Y-m-d H:i:s');
$sql1 = "UPDATE clearance SET ClearanceDate= $date WHERE RequestorID = $rqstorID AND RequesteeID = $usrID AND StoryID = $stryID";
//The mysql query causing the error
I can't seem to find the cause of this error as I checked the column names thoroughly and just for clarification ClearanceDate is of type datetime. Thanks in advance.
EDIT: Thank you for the helpful input from you all and for directing me to the similar question. I just put the $date variable in single quotes and it worked like a charm.