0

I am trying to update the last login date in my database each time a user logs into the website. It currently updates the LastLogin with a null value?

Why does the below code not work?

$this->mysqli->query("Update adminusers SET LastLogin = DATE('yyyy-mm-dd') WHERE Username = 'admin'");

Thanks!

2
  • RTFM? dev.mysql.com/doc/refman/5.5/en/… Commented Dec 2, 2014 at 20:04
  • @Rafael session value of the current date ? eh why ?? Commented Dec 2, 2014 at 20:07

1 Answer 1

1

You are not using the DATE() function properly. You should use CURDATE() for current date in yyyy-mm-dd format

$this->mysqli->query("UPDATE adminusers SET LastLogin = CURDATE() WHERE Username = 'admin'");
Sign up to request clarification or add additional context in comments.

1 Comment

DATE(NOW()) should be CURDATE()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.