Monday, 7 August 2017

php - How to update SQL date using NOW()




Basically I have a simple login form. In the database I have a 'last_logged' column and would like to update it with the current date and time every time someone logs in.



I currently have this query:



    UPDATE users SET last_logged = "NOW()" WHERE id = 1


But it doesn't update the column to the current date. Any ideas why?



Answer



Remove the quotes from NOW(). As a function call, it should be unquoted.



UPDATE users SET last_logged = NOW() WHERE id = 1

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...