Problem With Users Online

saqib389saqib389 BeginnerLink Clerk
this code is always showing me...... like this

People Online:
Guests Online: 0
Members Online: 0


i m online in my site.. and registered users are also online.. but still its showing this output in this code
please any one can help me




<?

$dbhost = 'localhost'; 
$dbusername = ''; 
$dbpasswd = ''; 
$database_name = 'l'; 

#under here, don't touch! 
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") 
    or die ("Couldn't connect to server."); 
$db = mysql_select_db("$database_name", $connection) 
    or die("Couldn't select database."); 




if(!session_is_registered('userid')){ 
    @mysql_query("INSERT INTO ppl_online (session_id, activity, ip_address, refurl, user_agent) <br>        VALUES ('".session_id()."', now(), '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_REFERER']}', '{$_SERVER['HTTP_USER_AGENT']}')"); 
    session_register('userid'); 
} else { 
    if(session_is_registered('userid')){ 
        @mysql_query("UPDATE ppl_online SET activity=now(), member='y' WHERE session_id='".session_id()."'"); 
    } 
} 
if(session_is_registered('userid')){         
    @mysql_query("UPDATE ppl_online SET activity=now() WHERE session_id='".session_id()."'"); 
} 




// This file is included into your website 
// Preferably a MySQL connection has been established already 

$limit_time = time() - 300; // 5 Minute time out. 60 * 5 = 300 
$sql = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time AND member='n' GROUP BY ip_address") or die (mysql_error()); 
$sql_member = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time AND member='y' GROUP BY ip_address") or die (mysql_error()); 
$visits = mysql_num_rows($sql); 
$members = mysql_num_rows($sql_member); 

echo "People Online:<br />"; 
echo "Guests Online: $visits<br />"; 
echo "Members Online: $members<br />"; 

// Database connection information here 

$maxtime = time() -600; 
$sql = mysql_query("DELETE FROM ppl_online WHERE UNIX_TIMESTAMP(activity) < '$maxtime'"); 
$rows = mysql_affected_rows(); 

echo "Total of $rows Deleted"; 

?>
Sign In or Register to comment.