unidox Posted August 27, 2008 Share Posted August 27, 2008 I am getting this error: Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. Here is my login code: $q = mysql_query("SELECT * FROM `pcp_users` WHERE `username` = '$username' AND `password` = '$password' LIMIT 1"); if (mysql_num_rows($q) > 0) { $name = $r['name']; $level = $r['level']; $date = "" . date('l dS \of F Y h:i:s A') . " EST"; $_SESSION['name'] = $name; $_SESSION['username'] = $username; $_SESSION['level'] = $level; mysql_query("UPDATE `pcp_users` SET `date` = '$date' WHERE `password` = '$password' AND `username` = '$username'"); header("Location: index.php?p=user_home"); exit(); } else { $error = "Incorrect username/password. Please try again!"; } that code is included inside index.php which contains ob_start/flush. I get that error every time I login, but if I refresh the page, the error goes away. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/121608-solved-help/ Share on other sites More sharing options...
mrMarcus Posted August 27, 2008 Share Posted August 27, 2008 there must be more to your code than that .. where are you getting $username from? is it being submitted through a form? if so, are you using a POST method, cause as far as i know, with GLOBAL variables you used to not have to use, ex. $username = $_POST['username'];, but instead just $username would suffice .. please correct me if i'm wrong .. but now it's mandatory so long as register_globals is turned off. Link to comment https://forums.phpfreaks.com/topic/121608-solved-help/#findComment-627295 Share on other sites More sharing options...
revraz Posted August 27, 2008 Share Posted August 27, 2008 Also, where is your session_start at? Link to comment https://forums.phpfreaks.com/topic/121608-solved-help/#findComment-627297 Share on other sites More sharing options...
PFMaBiSmAd Posted August 27, 2008 Share Posted August 27, 2008 The error occurs when you have a program variable and a session variable with the same name and one of them gets set to a null value. The buggy register_globals code (even with register_globals off) thinks you want to cross-set the two different variables. You can either change the names so that your session/program variables don't have the same name or you can set the php.ini flag(s) that are mentioned in the error message to suppressor the error. Link to comment https://forums.phpfreaks.com/topic/121608-solved-help/#findComment-627298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.