TINNY Posted December 10, 2004 Report Posted December 10, 2004 Anyone care to help my problem with PHP?I got the script for to get the number of users currently online on a website. the problem is that it only counts the users online on that page, not the whole website. therefore i have to put it on each page (i have over 4000 pages) which is unpractical. so can anyone modify or suggest a better code that would work from this one:http://www.devarticles.com/c/a/MySQL/Display-Users-Online-Based-On-Page-Viewing/1/i appreciate your help PS: Is it ok for me to treat this category for computer problems? Quote
Tormod Posted December 10, 2004 Report Posted December 10, 2004 PS: Is it ok for me to treat this category for computer problems? I'm still learning PHP myself but I think it is perfectly fine to post help requests here. Alexander is a PHP programmer. ;) Quote
TINNY Posted December 10, 2004 Author Report Posted December 10, 2004 Alexander is a PHP programmer.Hope he's willing to help, which I'm very sure he will. ;) Quote
TINNY Posted December 10, 2004 Author Report Posted December 10, 2004 wait. PHP is scripting not programming right?*inner speech* "Tinny, go get some sleep ok?" *inner speech* Quote
TINNY Posted December 11, 2004 Author Report Posted December 11, 2004 I guess no one here is good at PHP huh? Quote
Tormod Posted December 11, 2004 Report Posted December 11, 2004 I think it is weekend, Tinny. ;) Quote
TINNY Posted December 12, 2004 Author Report Posted December 12, 2004 good. so i can remain hopefuli thought people are online longer on weekends. i'm experiencing my first weekend with a computer and internet connection... Quote
alexander Posted December 13, 2004 Report Posted December 13, 2004 Is it ok for me to treat this category for computer problems?[/Quote]Remember, this section was called "Computer Programming" in the past, plus remember i posted in "xrand reloaded" thread a whole bunch of code? So yes this is very appropriate and welcome here! You have to excuse me, i tend to be away for weekends, job, school work, you know how it goes...Anyone care to help my problem with PHP?[/Quote] any time well, there are a few scripts out there:http://www.hotscripts.com/Detailed/30848.htmlhttp://www.hotscripts.com/Detailed/24313.htmlhttp://www.hotscripts.com/Detailed/33868.htmlhttp://www.hotscripts.com/Detailed/32703.htmlhttp://www.hotscripts.com/Detailed/29639.htmlhttp://www.hotscripts.com/Detailed/22779.htmlhttp://www.hotscripts.com/Detailed/21551.htmlhttp://www.hotscripts.com/Detailed/13997.html Tormod 1 Quote
alexander Posted December 13, 2004 Report Posted December 13, 2004 Patience is a virtue, but never pay a full price for a late pizza... Quote
TINNY Posted December 13, 2004 Author Report Posted December 13, 2004 Thank you very much but it wasn't of much help.... I actually have tried almost all the php free scripts available on the internet prior to giving up and hoping alex would solve it. theones on the net ALL work the same. the method used is the timeout method.the problem is here:$timeout = time() - 300 //this is in secondsso the query goes: "delete from database where timevisit<timeout"$result = "select distinct IP from database"$user = number_of_rows($result)to display it, it goes:there are $user users online. So basically, you don't know when the visitor exits the website. the code simply deletes the IPs of visitors who registered their IP more than five minutes (300 seconds) ago. so if the visiotr is still on the site more than five minutes they will not be counted as one that is currently online. or, if the visitor left after a minute, the visitor will still be counted as online. that would make it totally inaccurate. ONe more thing, do you know how the '$REMOTE_ADDR' variable obtains the IP address of visitors.because I compared the list of IPs using that variable and the list of IPs obtained from the statistics software and they were different. the statistics software records more IPs. it seems the '$REMOTE_ADDR' variable doesn't pick up certain IPs. how is this? or is the webalizer software wrong.FIY, webalizer as well as most others i know obtain the info from the log file. is it the same with '$REMOTE_ADDR'? if not, where do i find the log file?thanks for reading... ;) Quote
Tormod Posted December 13, 2004 Report Posted December 13, 2004 Session timeout is always a problem. 5 minutes is too short, though. At Hypography this is set to 15 minutes, I think. So if you read an article for 15 minutes, then post, you might be counted as two visitors in the stats. But the "Users online right now" will be correct until the 16th minute. However, when you reload you will again be counted so this isn't a real problem. Quote
Tormod Posted December 13, 2004 Report Posted December 13, 2004 $REMOTE_ADDR is a PHP server variable which provides the referral address. This is not received from the log but from the browser, and is then stored in the log. Quote
TINNY Posted December 13, 2004 Author Report Posted December 13, 2004 $REMOTE_ADDR is a PHP server variable which provides the referral address. This is not received from the log but from the browser, and is then stored in the log.oh.. i see. how do you know that? is it accurate? have you compared it with the statistics software?maybe obtaining it from the log file is better? how does the browser provide the IP?i'm quite sure there's something wrong with the $REMOTE_ADDR thingy. Quote
Tormod Posted December 13, 2004 Report Posted December 13, 2004 I would not do anything towards the log files as they are constantly being updated by the server. I don't know what you mean with "accurate" - it simply contains the full URL from which the user has arrived to your site (so if the previous page was on your site, it will contain the full url to some page on your site. It is as accurate as it gets - that means, nothing is quite reliable and accurate when it comes to web statistics. I think you will find that your numbers will never add upp correctly no matter how you try. So go for an approximation and you should be fine. Quote
TINNY Posted December 13, 2004 Author Report Posted December 13, 2004 I don't know what you mean with "accurate" - it simply contains the full URL from which the user has arrived to your site (so if the previous page was on your site, it will contain the full url to some page on your siteno, the variable is for retrieving people's IP address, not previous url. i'm just wondering that perhaps certain people's IPs aren't available through that variable. coz it doesn't show all the ip's that i find from the webalizer program. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.