jordanwb Posted December 17, 2008 Share Posted December 17, 2008 I have a table like so: CREATE TABLE `jscm_login_attempts` ( `user_id` int(11) NOT NULL, `user_attempts` tinyint(2) NOT NULL, `user_locked_out` tinyint(1) NOT NULL, `user_locked_out_till` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; When a user tries to login, a row will be inserted with the user's id, attempts made, false, and the current timestamp. If and when the "user_attempts" field reaches a preset number (say 3), "user_locked_out" will be set to true. That I know how to do but what I want to do is change the timestamp so its X number of minutes in the future (say 15). How would I do that? Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/ Share on other sites More sharing options...
xtopolis Posted December 18, 2008 Share Posted December 18, 2008 Here is an example of selecting the current time, and the time + 15 minutes. SELECT CURRENT_TIMESTAMP(),DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL + 15 MINUTE); You could also do this in php using functions like date and strtotime. Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-718483 Share on other sites More sharing options...
jordanwb Posted December 18, 2008 Author Share Posted December 18, 2008 You could also do this in php using functions like date and strtotime. Oh yeah, I forgot about that. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-718767 Share on other sites More sharing options...
fenway Posted December 18, 2008 Share Posted December 18, 2008 That syntax before was incorrect... try SELECT CURRENT_TIMESTAMP() + INTERVAL 15 MINUTE Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-718921 Share on other sites More sharing options...
jordanwb Posted December 18, 2008 Author Share Posted December 18, 2008 That syntax before was incorrect... try SELECT CURRENT_TIMESTAMP() + INTERVAL 15 MINUTE So I'd put that (minus the SELECT) in the UPDATE query, right? Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-718989 Share on other sites More sharing options...
jordanwb Posted December 18, 2008 Author Share Posted December 18, 2008 I wish I could edit my posts. What if the Interval was >= 60 minutes? Would MySQL be smart enough to know its one hour? Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-719057 Share on other sites More sharing options...
fenway Posted December 19, 2008 Share Posted December 19, 2008 I don't know what you mean by that... an interval can't be an inequality... but you can use an inequailty in your comparison. and there is a "1 HOUR" option too. Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-719645 Share on other sites More sharing options...
jordanwb Posted December 19, 2008 Author Share Posted December 19, 2008 I don't know what you mean by that... an interval can't be an inequality... but you can use an inequailty in your comparison. and there is a "1 HOUR" option too. Don't worry about it. I got it all figured out. Quote Link to comment https://forums.phpfreaks.com/topic/137453-solved-using-the-timestamp-field-type/#findComment-719903 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.