473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why online users script doesn't show proper user count?

I have a user count script thats well on my local host.
I uploaded it into my webserver and it always shows 1 user online and even when i login from diferent ip addresses.
The codes of my script is below.
Please help
Expand|Select|Wrap|Line Numbers
  1.  
  2. $server             = "localhost";          
  3. $db_user            = "root";            
  4. $db_pass            = "root";                                   
  5. $database               ="test"                                      
  6.  
  7. $timeoutseconds     = 200;    
  8.  
  9. $timestamp=time();                                                                                            
  10. $timeout=$timestamp-$timeoutseconds;  
  11. //$test=getenv("REMOTE_ADDR")
  12. mysql_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");                                                                   
  13. mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')") or die("Useronline Database INSERT Error"); 
  14. mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout") or die("Useronline Database DELETE Error");
  15. $result=mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'") or die("Useronline Database SELECT Error");
  16. $user  =mysql_num_rows($result);                                                                              
  17. mysql_close();                                                                                                
  18. if ($user==1) {echo"<font size=1>$user Star(s) curently online.</font>";} else {echo"<font size=1> $user Star(s) curently online.";}
  19. ?>
  20.  
  21.  
Jan 27 '11 #1
3 2166
Markus
6,050 Expert 4TB
If you examine the database after visiting the page, do you see multiple entries?
Jan 27 '11 #2
It captures the timestamp only.
The IP (IP address) and file is not captured.
Jan 28 '11 #3
Markus
6,050 Expert 4TB
$REMOTE_ADDR? Do you mean $_SERVER['REMOTE_ADDR']? The same goes for $PHP_SELF. I do hope you're not using register globals. Also, are you seeing multiple entries in your database, if you have multiple visitors?
Jan 28 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Daniel L. | last post by:
Hi, I've searched over 1 hour on Google and elsewhere and haven't found anything. I'd like to find a way to get the real active user count on our website. THe main problem I have is when a...
5
by: cc | last post by:
From the popular website At this link: http://www.w3schools.com/asp/asp_globalasa.asp I got this code, but it does not work on my server... I can open three IE browsers and watch the count go to...
6
by: KS | last post by:
I have made a WebForm with log ON/OFF off users. There is a label that shows the total count off users logged on stored in Application("UserCount") It works fine if the users logs out WITH THE...
1
by: Bar?? | last post by:
Hi, I want to show number of active users (login users) on my web page. Creating the number of activate users is easy. I increased an application variable (Application("numOfUsers")) by one when...
5
by: Luis E Valencia | last post by:
I want to show how many visitors do I have at my website, If the user is logged I must show it on the list. If there 5 users not logged I must show 5 Guests.
5
by: GaryDean | last post by:
Using 1.1.... I have an application using Forms Authentication that, like all other such applicaitons, uses FormsAuthentication.RedirectFromLoginPage to authenticate a user. at a point in time...
1
by: arun.hallan | last post by:
Hi, I have an service that runs everynight. It needs to inform the users of any errors that occur. Whats the best way to do this? I'm using email at the moment, but I was thinking some...
32
by: Ciaran | last post by:
Hi I've seen this a few places - The site lists off the number of people (not logged in) currently browsing the site. How can I do this with php / mySQL please?
2
by: thesti | last post by:
hi, how to count the number of online user in a website? i know how to count online user using the global.asa . for some reasons. if there exists, i prefer another way that doesn't involve...
4
by: tim007 | last post by:
Hi, How can we get tthe number of active users connected to our web application. I have added application varible that gets incrimeted at session_start and then is decreased at session_end ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.