clown[NOR] Posted May 18, 2007 Share Posted May 18, 2007 everytime a user who's logged in refreshes the control panel, I need to update the timestamp in the database for the user... but it wont update... can anyone see what might be causing it? this is the validation function I run on top of every page: <?php function valUser($epost) { $axx = $_COOKIE['axx']; $sid = $_COOKIE['sid']; if (!empty($axx) && !empty($sid)) { c2db(); $epost = secureSQL($epost); $axx = secureSQL($axx); $sid = secureSQL($sid); $query = " SELECT * FROM `news_users` WHERE `email` = '".$epost."' AND `access` = '".$axx."' AND `sid` = '".$sid."' AND `authorized` = '1' LIMIT 1 "; $result = mysql_query($query); if (!$result) { die(mysql_error()); } $dbRows = mysql_num_rows($result); if ($dbRows == 1) { $dbField = mysql_fetch_array($result); $last_active = strtotime($dbField['timestamp']); $idle = strtotime(date("Y-m-d H:i:s", strtotime("5 minutes ago"))); if ($idle > $last_active) { setcookie("epost", "", time()-3600); setcookie("axx", "", time()-3600); setcookie("sid", "", time()-3600); return 0; } elseif ($idle < $last_active) { updateTimestamp($epost,$axx,$sid); return 1; } } else { header("Location: index.php"); } } } ?> this is the updateTimestamp() function <?php function updateTimestamp($epost,$axx,$sid) { c2db(); $new_time = secureSQL(date("Y-m-d H:i:s")); $epost = secureSQL($epost); $axx = secureSQL($axx); $sid = secureSQL($sid); $query = " UPDATE `news_users` SET `timestamp` = '".$new_time."' WHERE `email` = '".$user."' AND `sid` = '".$sid."' AND `access` = '".$axx."' LIMIT 1 "; $result = mysql_query($query); if (!$result) { die(mysql_error()); } setcookie("epost", "", time()-3600); setcookie("axx", "", time()-3600); setcookie("sid", "", time()-3600); setcookie("epost", $epost, time()+3600); setcookie("axx", $axx, time()+3600); setcookie("sid", $sid, time()+3600); } ?> this is what I run on top of every page <?php if (isset($_COOKIE['epost']) && !empty($_COOKIE['epost'])) { $epost = $_COOKIE['epost']; $valUser = valUser($epost); if ($valUser == 0) { header("Location: index.php"); } } else { header("Location: index.php"); } ?> Thanks In Advance - Clown Quote Link to comment https://forums.phpfreaks.com/topic/52024-help-somethings-wrong-but-i-cant-find-the-error/ Share on other sites More sharing options...
Wildbug Posted May 18, 2007 Share Posted May 18, 2007 Did you puke out the query? What's it look like? Quote Link to comment https://forums.phpfreaks.com/topic/52024-help-somethings-wrong-but-i-cant-find-the-error/#findComment-256464 Share on other sites More sharing options...
clown[NOR] Posted May 19, 2007 Author Share Posted May 19, 2007 what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/52024-help-somethings-wrong-but-i-cant-find-the-error/#findComment-256983 Share on other sites More sharing options...
Wildbug Posted May 19, 2007 Share Posted May 19, 2007 Did you output the query that is assembled in your script to see that it's correct? Also, have you checked for any mysql_error()s? Quote Link to comment https://forums.phpfreaks.com/topic/52024-help-somethings-wrong-but-i-cant-find-the-error/#findComment-257118 Share on other sites More sharing options...
sasa Posted May 19, 2007 Share Posted May 19, 2007 where you set variable $user? (function updateTimestamp()) Quote Link to comment https://forums.phpfreaks.com/topic/52024-help-somethings-wrong-but-i-cant-find-the-error/#findComment-257163 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.