Recent Topics

1 Feb 13, 2005 21:08    

Okay, I'm trying to create a hack to show the # of guests and # of users and their usernames. The table (which i've placed in B2Evo's db) looks like this:


Table name: whos_online

Fields:

id      int(10)      not null      auto_increment      primary
ip      varchar(15)      not null
time      varchar(15)      not null
name      varchar(30)      not null


Hokay? Then I created a file (_whosonline.php) within my 'custom' skin folder, the contents look like this:


<?php

// how long you want before a guest is inactive. 
// I set it to 300 secs (5mins)
$info[life] = 180;
$info[username] = $user_login = @mysql_fetch_array(@mysql_query("select * from evo_users where users_login = '$username'"));

 // put here the code to get the user browsings username



// Do not edit below, unless you know how too



$info[table] = 'whos_online';
$info[ip] = $REMOTE_ADDR;
$info[time] = time();
$info[time_work] = $info[time] - $info[life];

mysql_query("delete from $info[table] where time < '$info[time_work]'");

$check = mysql_fetch_array(mysql_query("select * from $info[table] where ip = '$info[ip]'"));

if($check)
{
     mysql_query("update $info[table] set time = '$info[time]', name = '$info[username]' where ip = '$info[ip]'");
}
else
{
     mysql_query("insert into $info[table](ip,time,name) values('$info[ip]','$info[time]','$info[username]')");
}

?>


Okay, so I tried to place the info within my page like so:


<?php

$info[table] = 'whos_online';
$info[guests_online] = mysql_num_rows(mysql_query("select * from $info[table] where name = ''"));
$info[members_online] = mysql_num_rows(mysql_query("select * from $info[table] where name != 'evo_users'"));

echo '<b>Guests Online:</b> ' . $info[guests_online];
echo '<br /><br /><b>Members Online:</b> ' . $info[members_online];

?>

And:


<?php

$members_online_query = mysql_query("select * from whos_online where name != ''");

while($info = mysql_fetch_array($members_online_query))
{
       echo $info[name] . " ";
}

?>


That first code is supposed to show the number of guests and members online, while the second is supposed to list the names of logged on members, but, it's not working. All I can get it to show is:

Guests Online: 1

Members Online: 1

And it doesnt change - even when I log out... Help!! (www.bunchofmorons.com is where it's being used...)

2 Feb 13, 2005 22:48



<?php

$info[table] = 'whos_online';
$info[guests_online] = mysql_num_rows(mysql_query("select * from $info[table] where name = ''"));
$info[members_online] = mysql_num_rows(mysql_query("select * from $info[table] where name != 'evo_users'"));

echo '<b>Guests Online:</b> ' . $info[guests_online];
echo '<br /><br /><b>Members Online:</b> ' . $info[members_online];

?> 

Ok, this there, it would appear you would be counting all the guests as members
you have where name = '' for guests, and where name !='evo_users' for members - which would also include people without names ?


time      varchar(15)      not null 


maybe make that int instead of varchar ? =)

as for the rest - sorry can't help with that at the moment i'm afraid :/

but i would suggest you check the $info[table] table in the db you created to see if your script is entering in the data it's suppose to =)

3 Feb 14, 2005 02:05

ahhh, Well, I'll try that and see what happens. I'm not really experienced with this stuff, I mostly made all that crap from tutorials i'd read... anyways, thanks for the help, we'll see if it works?

4 Feb 14, 2005 03:37

Nope, its just a real snafu, as always :P.


Form is loading...