Re: Undefined index ???

From: Date: Wed, 09 Jun 2004 20:27:07 +0000
Subject: Re: Undefined index ???
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-187980@lists.php.net to get a copy of this message
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. -- John C. Nichel KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#187980) next »