<?php
include ("config.php");
session_start();
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]);
}
update_sessions();
echo "There are currently ". get_onlineusers() ." users online.";
?>
I used this code to show how many users are online, but I get the following error:
Quote
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/dxportal.awardspace.com/index.php:10) in /home/www/dxportal.awardspace.com/index.php on line 40
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/dxportal.awardspace.com/index.php:10) in /home/www/dxportal.awardspace.com/index.php on line 40
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/dxportal.awardspace.com/index.php:10) in /home/www/dxportal.awardspace.com/index.php on line 40
Any help to get this fixed would be greatly appreciated.
Edited by Trix06, 01 October 2006 - 02:23 AM.
