Re: 1 last error to fix before the application is done!

From: Date: Tue, 14 Oct 2008 12:51:53 +0000
Subject: Re: 1 last error to fix before the application is done!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-281863@lists.php.net to get a copy of this message
Jason Pruim wrote: > Good morning everyone! > > I think I might be having a "to early in the morning/not enough > caffeine" moment... But I am down to 1 error on my timecard application > that I would like to clean up. It's a small undefined index error, and > the program works jsut fine the way it is, but why leave an error if you > don't need to? :) > > Here is the error: > > [Tue Oct 14 08:19:47 2008] [error] PHP Notice: Undefined index: > userInfo in > /Volumes/RAIDer/webserver/Documents/dev/stimecard/inc/function/authentication.func.php > on line 22 > > and here is the relevant code: > > ======> Line 22 if($_SESSION['userInfo']['loggedin'] == TRUE) { > Surely all you need here is to test existence first: if (isset($_SESSION['userInfo']) && isset($_SESSION['userInfo']['loggedIn'] && $_SESSION['userInfo']['loggedin'] == TRUE) { You can probably short-circuit some of that - for example if $_SESSION['userInfo']['loggedIn'] is only ever set to TRUE (and is not set otherwise) then you might find that if (isset($_SESSION['userInfo']['loggedin'])) { will work for you ... -- Peter Ford phone: 01580 893333 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent

« previous php.general (#281863) next »