redarrow Posted January 4, 2008 Share Posted January 4, 2008 ok babes as long as ur happy Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430230 Share on other sites More sharing options...
Colleen78 Posted January 4, 2008 Author Share Posted January 4, 2008 I am very happy, you went above and beyond, I really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430233 Share on other sites More sharing options...
redarrow Posted January 4, 2008 Share Posted January 4, 2008 RE EDITED NOW DEF WORKS now there a entry we need to get lastactivity in the databse to update each time correctly trying to throw the database around to show the lastactivety and last access correctly get me babes try <?php // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); $time_now=time(); //$time_now=strtotime(date("dmy"));// if timestamp in database $time_now=mysql_real_escape_string($_POST['time_now']); $userid=mysql_real_escape_string($_POST['userid']); $result1 = mysql_query("SELECT * FROM user WHERE userid = '503'") or die(mysql_error()); while($row1=mysql_fetch_assoc($result1)){ $time_now2=$_POST['time_now2']; $time_now2=$row1['lastactivity']; $result = mysql_query("UPDATE user SET lastactivity='$time_now', lastvisit='$time_now2' WHERE userid='503' ") or die(mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430242 Share on other sites More sharing options...
aschk Posted January 4, 2008 Share Posted January 4, 2008 Guys DON'T use PHP to calculate the datetime, use MySQLs nice handy built in functions. i.e. use CURRENT_TIMESTAMP or NOW() thus $sql = "UPDATE user SET lastactivity=CURRENT_TIMESTAMP WHERE userid='503' "; $result = mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430250 Share on other sites More sharing options...
redarrow Posted January 4, 2008 Share Posted January 4, 2008 were do it my way sorry it works fine but i agree mysql functions are nice Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430255 Share on other sites More sharing options...
redarrow Posted January 4, 2008 Share Posted January 4, 2008 end result hope it works tell me <?php // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); $userid=mysql_real_escape_string($_POST['userid']); $result1 = mysql_query("SELECT * FROM user WHERE userid = '503'") or die(mysql_error()); while($row1=mysql_fetch_assoc($result1)){ $time_now2=mysql_real_escape_string($_POST['time_now2']); $time_now2=$row1['lastactivity']; $result = mysql_query("UPDATE user SET lastactivity=NOW(), lastvisit='$time_now2' WHERE userid='503' ") or die(mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-430259 Share on other sites More sharing options...
Colleen78 Posted January 5, 2008 Author Share Posted January 5, 2008 Thanks redarrow, I am going to try that out in a few and let you know what happens. Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-431475 Share on other sites More sharing options...
Colleen78 Posted January 5, 2008 Author Share Posted January 5, 2008 redarrow, your latest code above causes the date to change to "Last Activity: Dec 31st, 1969 7:33 pm" Your earlier code was working fine. Quote Link to comment https://forums.phpfreaks.com/topic/84441-need-help-with-script-which-will-keep-member-logged-in-using-cron/page/2/#findComment-431490 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.