MadnessRed Posted July 4, 2009 Share Posted July 4, 2009 I seem to be loosing variables. Here is my code echo "[".$_SESSION['user']."]<br />"; $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Login` = '".$_SESSION['user']."' AND LIMIT 1 ;")); echo "[".$_SESSION['user']."]<br />"; and here is the output. Why does php loose the value of $_SESSION['user'] when I try and use it? [Anthony] [] Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/ Share on other sites More sharing options...
mattal999 Posted July 4, 2009 Share Posted July 4, 2009 Possibly something to do with your PHP version. I have seen before that you can use variables like $user to grab the value of $_REQUEST['user'] automatically. Try this: echo "[".$_SESSION['user']."]<br />"; $query = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Login` = '".$_SESSION['user']."' AND LIMIT 1 ;")); echo "[".$_SESSION['user']."]<br />"; Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/#findComment-868900 Share on other sites More sharing options...
PFMaBiSmAd Posted July 4, 2009 Share Posted July 4, 2009 Because register_globals are on. Turn them off as quick as possible. They were turned off by default in php4.2 in the year 2002, but a lot of people did not get the message on how dangerous they are. $user, $_POST['user'], $_GET['user'], $_COOKIE['user'], and $_SESSION['user'] are all cross populated when register_globals are on. Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/#findComment-868901 Share on other sites More sharing options...
MadnessRed Posted July 4, 2009 Author Share Posted July 4, 2009 Because register_globals are on. Turn them off as quick as possible. They were turned off by default in php4.2 in the year 2002, but a lot of people did not get the message on how dangerous they are. $user, $_POST['user'], $_GET['user'], $_COOKIE['user'], and $_SESSION['user'] are all cross populated when register_globals are on. ok many thanks, is it possible to turn them off without access to php.ini Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/#findComment-868907 Share on other sites More sharing options...
Daniel0 Posted July 4, 2009 Share Posted July 4, 2009 If you're running PHP as an Apache module you can add this to a .htaccess file: php_flag register_globals Off Then send an email to your host requesting that they hire competent sysadmins. Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/#findComment-868920 Share on other sites More sharing options...
MadnessRed Posted July 4, 2009 Author Share Posted July 4, 2009 If you're running PHP as an Apache module you can add this to a .htaccess file: php_flag register_globals Off Then send an email to your host requesting that they hire competent sysadmins. ok many thanks ps, its not my host, im helping out someone else on their server. Quote Link to comment https://forums.phpfreaks.com/topic/164773-solved-php-is-loosing-variables/#findComment-868939 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.