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. Quote Link to comment 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() Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.