Jump to content


Photo

How many online users


  • Please log in to reply
2 replies to this topic

#1 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 25 April 2006 - 10:05 PM

I have been working on this script:

<?php
include 'config.php';
mysql_connect("$host", "$user", "$pass") or die(mysql_error());
mysql_select_db("$dbname") or die(mysql_error());


function update_sessions()
{
    $sid = session_id();
    if($_SESSION['sitename_online'] == "1")
    {
        mysql_query("UPDATE `sessions` SET `time` = '". time() ."' WHERE `sid` = '$sid'") or die(mysql_error());
    }
    else
    {
        $_SESSION['sitename_online'] = 1;
        mysql_query("INSERT INTO `sessions` SET `time` = '". time() ."', `sid` = '$sid'") or die(mysql_error());
    }
}
function get_onlineusers()
{
    $min = time() - 301;
    mysql_query("DELETE FROM `sessions` WHERE `time` <= '$min'") or die(mysql_error());
    $query = mysql_query("SELECT COUNT(sid) FROM `sessions`");
    $num = mysql_fetch_row($query);
    return($num[0]);
}
$online_users = get_onlineusers();
echo("$online_users");
?>


It should say how many unique visitors are online At this moment and it should change every x minuits.

It doesn't show anything but 0,

What's te problem?

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 25 April 2006 - 11:28 PM

are you executing the first function (update sessions) anywhere? Also at the top of the page are you using session_start(); ?
If you're not part of the solution, you're part of the precipitate

#3 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 26 April 2006 - 04:36 PM

so what do I need to change?

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users