Re: What do these errors mean?

From: Date: Fri, 21 Feb 2003 19:09:04 +0000
Subject: Re: What do these errors mean?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136556@lists.php.net to get a copy of this message
> I was looking through php.ini and noticed that show_error was set to Off. I > turned it On, and now I see these errors on one of my pages: > Notice: Use of undefined constant option - assumed 'option' in > /usr/local/apache/htdocs/tyler/encodeDecode.php on line 37 > > Notice: Undefined index: option in > /usr/local/apache/htdocs/tyler/encodeDecode.php on line 37 > > Here's line 37-42: > if ($_GET[option] == "") { > print "<font face=Arial size=4><b>Add Credit > Card</b></font><br>"; > print "<form method=POST action=encodeDecode.php?option=encrypt> > <font face=Arial size=2><b>Credit Card Number:</b></font> <input type=text > name=cc><br> > <input type=submit value=Add></form>"; > } > > What's wrong with that? Where you have $_GET[option], PHP is assuming that _option_ is a constant, since strings have quotes around them (array indexes are strings). Since there is no constant with that name, though, PHP will then assume that you meant to use a string. The second "warning" is caused because there is no index in the _GET array named "option", so it's an "undefined index" You should be using this: if(isset($_GET['option'])) { //code... } ---John Holmes...

« previous php.general (#136556) next »