Jump to content

online user help


mattm1712

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.