MySql Update Query

I am trying to update a record in a table called 'user_access' to record the last login time in a field called 'last_login'. I am trying the query below without luck.

Can anyone see where I am going wrong.
mysql_query("UPDATE user_access SET last_login = '$date' WHERE user_id = '$username'")or die(mysql_error());

Open in new window

abdulvAsked:
Who is Participating?
 
wwwdeveloper2Connect With a Mentor Commented:

MySQL does have a curdate() function that will automatically grab the date,so you won't have to do it with PHP:

mysql_query("UPDATE user_access SET last_login = CURDATE() WHERE user_id = '$username'")or die(mysql_error());

Here is a couple of examples:

http://www.tizag.com/mysqlTutorial/mysql-date.php
http://www.ntchosting.com/mysql/insert-date.html
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what is the problem?
note that date fields MUST have format YYYY-MM-DD to be updated correctly ...
0
All Courses

From novice to tech pro — start learning today.