mattm1712 Posted December 18, 2010 Share Posted December 18, 2010 im trying to count and display the number on users on my site this is the coding im using cant see where im going wrong, its inserted into the data base correctly but wont delete after 60 seconds, cheers matt $session=session_id(); $time=time(); $time_check=$time-60; $sql="SELECT * FROM onlineusers WHERE session='$session'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count=="0"){ $sql1="INSERT INTO onlineusers(session, time, username)VALUES('$session', '$time', '$username')"; $result1=mysql_query($sql1); } else { "$sql2=UPDATE onlineusers SET time='$time' WHERE session = '$session'"; $result2=mysql_query($sql2); } $sql3="SELECT * FROM onlineusers"; $result3=mysql_query($sql3); $count_user_online=mysql_num_rows($result3); $sql4="DELETE FROM onlineusers WHERE time<$time_check"; $result4=mysql_query($sql4); Link to comment https://forums.phpfreaks.com/topic/222070-online-user-help/ Share on other sites More sharing options...
BlueSkyIS Posted December 18, 2010 Share Posted December 18, 2010 in your delete query, time will never be < $time_check since $time_check = time() - 60. Link to comment https://forums.phpfreaks.com/topic/222070-online-user-help/#findComment-1149014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.