Re: Newbie - Undefined Index Variable

From: Date: Fri, 07 Mar 2008 20:07:07 +0000
Subject: Re: Newbie - Undefined Index Variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-271146@lists.php.net to get a copy of this message
On Fri, Mar 7, 2008 at 2:59 PM, revDAVE <Cool@hosting4days.com> wrote: > I have this: > > <?php if (trim($_SESSION['nowtoctype']) == 'thistype') > > {print '<a href="page1.php">page1</a>';}else{print '<a > href=" > page2.php">page2</a>';} ?> > > I will get the error: > > Notice: Undefined index: nowtoctype in ... Check out isset(): http://php.net/isset <?php if(isset($_SESSION['nowtoctype']) && trim($_SESSION['nowtoctype']) == 'thistype') { echo "<a href=\"page1.php\">Page 1</a>\n"; } else { echo "<a href=\"page2.php\">Page 2</a>\n"; } ?> -- </Dan> Daniel P. Brown Senior Unix Geek <? while(1) { $me = $mind--; sleep(86400); } ?>

« previous php.general (#271146) next »