cheechm Posted November 11, 2007 Share Posted November 11, 2007 Hello, Whenever I run this I get: Notice: Use of undefined constant online - assumed 'online' function update_sessions() { $sid = session_id(); if($_SESSION[online] == "1") { mysql_query("UPDATE `sessions` SET `time` = '". time() ."' WHERE `sid` = '$sid'") or die(mysql_error()); } else { $_SESSION[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]); } What is the problem? Thanks Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 11, 2007 Share Posted November 11, 2007 Array keys which are not integers should be enclosed in single quotes, e.g.: $_SESSION['online'] You'll see them not done like this a lot of the time, since you only recieve a notice for this kind of minor error, and a lot of people have PHP set up not to report notices. Quote Link to comment Share on other sites More sharing options...
cheechm Posted November 11, 2007 Author Share Posted November 11, 2007 Cool thanks. How do I turn off error reporting? Thanks Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 11, 2007 Share Posted November 11, 2007 You can either set in your php.ini file or you can use the error_reporting() function if you only want to make the changes for one particular script. Quote Link to comment Share on other sites More sharing options...
cheechm Posted November 11, 2007 Author Share Posted November 11, 2007 Also what is cross site scripting? Thanks Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 11, 2007 Share Posted November 11, 2007 Slight change of subject there. I suggest you google - im sure you'll find what you need. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.