• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook pagefor updates, or we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.)

[RELEASE] Live Users (PHP)

Newbie Spellweaver
Joined
Dec 23, 2008
Messages
46
Reaction score
29
Here is a small script to list all user_id's that are currently online

WARNING!
- THIS PULLS 1 QUERY EVERY 3 SECONDS -
- Thats 20 query's in 1min
- Thats 1200 every hour!

You can change the time, on line 21 (in online.html) you'll find: 3000 = 3 sec


online.html
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<html xmlns="http://www.w3.org/1999/xhtml">
    
		<head>
        
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            
			<title>Live Users</title>
            
			<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
            
		</head>

	<body>
    
		<script type="text/javascript">
		
            setInterval(function(){
			
                $('#online').load('onlineusers.php');}, 3000);
				
        </script>
        
		<div id="online">Loading online list...</div>

	</body>
    
</html>


onlineusers.php
PHP:
<?php
	// Insert your MSSQL info here 
	$mssql = array( 
	'host' => "YOUR HOST", 
	'user' => "YOUR USER", 
	'pass' => "YOUR PASS" 
	); 
	
	$mslink = mssql_connect($mssql['host'],$mssql['user'],$mssql['pass']);


	$login = "1100";

	$result1 = mssql_query("SELECT * FROM account.dbo.user_profile WHERE login_flag = '".$login."' ",$mslink);
	
	while($array = mssql_fetch_array($result1)){
	
		echo $array['user_id'] . "<br>";
		
	}
?>
 
Newbie Spellweaver
Joined
Dec 23, 2010
Messages
55
Reaction score
0
how to fix this error
PHP:
Fatal error: Call to undefined function mssql_connect() in C:\Program Files\VertrigoServ\www\newreg\test.php on line 9
 
Back
Top