Hey, I have here a small amount of code to gather the # of active users... The script itself is fine (I think), but the session_start is giving me issues... Any help would be great!
PHP 5.2.*
MySQL 5.*
<passwordhere> is the actual pass on the normal script of course.
(problem below)
Code:
error received:Code:<?php mysql_connect('localhost', 'shadowte_shadow', '<passwordhere>'); mysql_select_db('shadowte_site'); session_start(); function update_sessions() { $sid = session_id(); if($_SESSION['sitename_online'] == "1") { mysql_query("UPDATE `shadow_sessions` SET `time` = '". time() ."' WHERE `sid` = '$sid'") or die(mysql_error()); } else { $_SESSION['sitename_online'] = 1; mysql_query("INSERT INTO `shadow_sessions` SET `time` = '". time() ."', `sid` = '$sid'") or die(mysql_error()); } } function get_onlineusers() { $min = time() - 301; mysql_query("DELETE FROM `shadow_sessions` WHERE `time` <= '$min'") or die(mysql_error()); $query = mysql_query("SELECT COUNT(sid) FROM `shadow_sessions`"); $num = mysql_fetch_row($query); return($num[0]); } update_sessions(); echo "There are currently ". get_onlineusers() ." users online."; ?>
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/shadowte/public_html/shadowtechstudios.net/php/usercount.php:9) in /home/shadowte/public_html/shadowtechstudios.net/php/usercount.php on line 10
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/shadowte/public_html/shadowtechstudios.net/php/usercount.php:9) in /home/shadowte/public_html/shadowtechstudios.net/php/usercount.php on line 10
No database selected
if you would like to see it yourself:
http://php.shadowtechstudios.net/usercount.php
Thanks again.
Update: after removing the html formating I do not recieve the php errors, however I do still get the no database selected... can someone tell me why it doesn't see what database i chose?



.
Reply With Quote

Bookmarks