pneudralics Posted May 3, 2009 Share Posted May 3, 2009 Database field for login is timestamp. Can't seem to update the login time when I click submit. Is the code below correct? //Update login datetime $updateloginq = "UPDATE user SET login = \"NOW()\" WHERE email = \"$email\" LIMIT 1"; mysql_query ($updateloginq); Link to comment https://forums.phpfreaks.com/topic/156709-solved-php-update-now-not-updating/ Share on other sites More sharing options...
fry2010 Posted May 3, 2009 Share Posted May 3, 2009 have you actually already inserted a time into it before hand? Otherwise you cant update. If so try to use CURTIME(). Although that will just be the time not date. Have you also specified in your table to use datetime, rather than just date. Link to comment https://forums.phpfreaks.com/topic/156709-solved-php-update-now-not-updating/#findComment-825196 Share on other sites More sharing options...
Axeia Posted May 3, 2009 Share Posted May 3, 2009 You're comparing to the string NOW() since you surrounded it with quotes. try //Update login datetime $updateloginq = "UPDATE user SET login = NOW() WHERE email = \"$email\" LIMIT 1"; mysql_query ($updateloginq); or better yet, //Update login datetime $updateloginq = "UPDATE user SET login = NOW() WHERE email = '$email' LIMIT 1"; mysql_query ($updateloginq); You're free to use single quotes inside double quotes without escaping them (and vice versa) Link to comment https://forums.phpfreaks.com/topic/156709-solved-php-update-now-not-updating/#findComment-825199 Share on other sites More sharing options...
fry2010 Posted May 3, 2009 Share Posted May 3, 2009 oh yeah... Link to comment https://forums.phpfreaks.com/topic/156709-solved-php-update-now-not-updating/#findComment-825200 Share on other sites More sharing options...
pneudralics Posted May 3, 2009 Author Share Posted May 3, 2009 You're comparing to the string NOW() since you surrounded it with quotes. try //Update login datetime $updateloginq = "UPDATE user SET login = NOW() WHERE email = \"$email\" LIMIT 1"; mysql_query ($updateloginq); or better yet, //Update login datetime $updateloginq = "UPDATE user SET login = NOW() WHERE email = '$email' LIMIT 1"; mysql_query ($updateloginq); You're free to use single quotes inside double quotes without escaping them (and vice versa) Thanks alot!! Link to comment https://forums.phpfreaks.com/topic/156709-solved-php-update-now-not-updating/#findComment-825203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.