"John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Michael Jonsson wrote: > > Hi > > > > Why do I get an error if the $_SESSION['user_status'] is NULL ??? > > > > > > ####Script###### > > session_start(); > > echo $_SESSION['user_status']; > > > > > > #####error###### > > Notice: Undefined index: user_status in > > /var/www/itmdata/include/include.php on line 13 > > > > > > > > Regards > > Micke > > > > > That's not an error. Three ways to solve this... > > 1) Turn down your error reporting level. > 2) Declare your variables before using them > > $_SESSION['user_status'] = NULL; > echo ( $_SESSION['user_status'] ); > > 3) Code for variables that may not exist > > if ( isset ( $_SESSION['user_status'] ) ) { > echo ( $_SESSION['user_status'] ); > } > > Or any combination of the three.
I would not recommend turning down the error reporting level. This might lead to unexpected behaviour in your application and makes it hard to back track errors. Always develop with error reporting set to E_ALL. You may set a lower level for your production environment and disable the display of errors: ini_set('display_errors', 0); Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php