tags:

views:

13

answers:

3

hi i'm receiving this error Notice: Undefined index: SESSION_ADMIN_MEMBER_TYPE in ... how do I go about fixing this error?

if((isset($_GET['p']) && $_GET['p'] != 'docs') 
&& ( $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'normal' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'restricted' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'c_account' ) )
+2  A: 

This means that SESSION_ADMIN_MEMBER_TYPE is not set (obviously). So you can add an additional check:

isset($_SESSION['SESSION_ADMIN_MEMBER_TYPE'])

to your conditional logic. Then you will suppress the notice and keep the same check. Make sure you are setting that session variable at the right time (and it is named correctly).

Note that this this notice is harmless. It is just to let you know that the key is not set.

tandu
By default, E_NOTICE is hidden. See [this aging post](http://www.brandonchecketts.com/archives/php-performance-isset-versus-empty-versus-php-notices) for the performance hit when adding isset() checks.
Adam Backstrom
A: 

THis is because you're checking the session variable before its set. So, add a check to see if its set first

if((isset($_GET['p']) && $_GET['p'] != 'docs' &&
isset($_SESSION["SESSION_ADMIN_MEMBER_TYPE"]))
&& ( $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'normal' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'restricted' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'c_account' ) )
Nigel
A: 
if((isset($_GET['p']) && $_GET['p'] != 'docs') 
&& isset($_SESSION["SESSION_ADMIN_MEMBER_TYPE"]) && ( $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'normal' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'restricted' 
|| $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] == 'c_account' ) )

By checking if $_SESSION["SESSION_ADMIN_MEMBER_TYPE"] is set

Bang Dao