PDA

View Full Version : Online Users Today


OnyxChase
12-16-2008, 05:21 AM
Hello,

I had a code that has worked for ages but for some reason today I noticed it was showing a completely OFF number, '13263'.

Basically I have an OFF-vBulletin script that needs this information. It is called using the following:


$timenow = time();
$datecut = $timenow - 86400;

mysql_connect('localhost', 'username', 'password');
mysql_select_db('database');

$result = mysql_query("SELECT COUNT(*) FROM vbulletin_session WHERE lastactivity > $datecut");
$result = mysql_fetch_array($result);

$onlineusercount = $result[0];

echo $onlineusercount . ' Users Online Today';


Anybody can figure out what I am doing wrong? It should be something in the 400 or 500 users online today, not 13000!

Lynne
12-16-2008, 02:40 PM
Have you looked at your session table to see how many rows are in it? Could something have happened to the cron job that removes sessions? (Although, with the time being a factor in the query, that shouldn't matter.) Try running that query by yourself (in the admin panel or phpMyAdmin) and see what the result is.

Deceptor
12-16-2008, 09:04 PM
Try change "SELECT COUNT(*)" to:
SELECT COUNT(*) AS `total`

Then use:

$onlineusercount = $result['total'];

Might help, not too certain :)