Potatis Posted March 10, 2008 Share Posted March 10, 2008 Can anybody tell me what is wrong with this code? I just want to record when a user logs on in a table. $query = "INSERT INTO login_log (username, ip, datetime) VALUES ('$user', '$ip', 'NOW()')"; The username and IP inserts fine, but the date/time is all zeros. I have tried setting my datetime column in my login_log table to datetime and tried timestamp, but I just get zeros. I'm not sure how I can get the date and time into the database, I have used search and spent a lot of time on Google, but nothing I have tried works. Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/95368-date-time-code-problem/ Share on other sites More sharing options...
Perad Posted March 10, 2008 Share Posted March 10, 2008 You do not need the single quotation marks around the NOW() Link to comment https://forums.phpfreaks.com/topic/95368-date-time-code-problem/#findComment-488412 Share on other sites More sharing options...
Baabu Posted March 10, 2008 Share Posted March 10, 2008 well i guess datetime is also a data type in mysql may be you should try to change the column name for datetime and then try Link to comment https://forums.phpfreaks.com/topic/95368-date-time-code-problem/#findComment-488415 Share on other sites More sharing options...
Potatis Posted March 10, 2008 Author Share Posted March 10, 2008 Thanks so much, Perad, that did the trick! Now I just have to try and get the time in my timezone. Link to comment https://forums.phpfreaks.com/topic/95368-date-time-code-problem/#findComment-488416 Share on other sites More sharing options...
Potatis Posted March 10, 2008 Author Share Posted March 10, 2008 Baabu, I didn't think that'd be a problem, but I'll change it to be sure it isn't! Link to comment https://forums.phpfreaks.com/topic/95368-date-time-code-problem/#findComment-488418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.