View Single Post
  Pocketx
 
 
Pocketx's Avatar
Registered User
 
Posts: 966
 
Reg: Jul 31 2002
 
ID: 1634
 
RP: 0
 
NBA 2k Series
Eminem
8 Mile, Rush Hour Series
Dreamcast
     
 
Default  12.19.02, 16:54:49
  Post #4 (permalink)
 
     

Contact me if u need help

PHP Code:
<?php 

$server 
"xxx"
$db_user "xxx"
$db_pass "xxx"
$database "xxx"
$timeoutseconds 300

$timestamp time(); 
$timeout $timestamp-$timeoutseconds

mysql_connect($server$db_user$db_pass); 
$insert mysql_db_query($database"INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); 
if(!(
$insert)) { 
 print 
"Useronline Insert Failed > "

$delete mysql_db_query($database"DELETE FROM useronline WHERE timestamp<$timeout"); 
if(!(
$delete)) { 
 print 
"Useronline Delete Failed > "

$result mysql_db_query($database"SELECT DISTINCT ip FROM useronline"); 
if(!(
$result)) { 
 print 
"Useronline Select Error > "

$user mysql_num_rows($result); 


mysql_close(); 
if(
$user == 1) { 
 print(
"<b>$user</b> user online\n"); 
} else { 
 print(
"<b>$user</b> users online\n"); 


?>
That is the script. Place is somewhere on ur site our create a online.php page and then include it

But not done, you have to create a mysql table

PHP Code:
CREATE TABLE useronline 
   
timestamp int(15) DEFAULT '0' NOT NULL
   
ip varchar(40NOT NULL
   
file varchar(100NOT NULL
   
PRIMARY KEY (timestamp), 
   
KEY ip (ip), 
   
KEY file (file
); 
Note: Replace the xxx in the script above with the real mysql information
  Pocketx is offline
View Pocketxs Profile! Find more posts by Pocketx! Visit Pocketxs Homepage!