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 Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/ 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. Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/#findComment-389351 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 Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/#findComment-389355 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. Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/#findComment-389367 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 Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/#findComment-389370 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. Link to comment https://forums.phpfreaks.com/topic/76900-solved-use-of-undefined-constant/#findComment-389379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.