Re: proper method to do the following...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 6 Oct 2004 06:53:34 -0700 (PDT), Hugh Beaumont
<hbeaumont@xxxxxxxxx> wrote:
> Notice: Undefined index: exact in search.php on line 10
> 
> code :
> 
> if (!isset($_POST['exact'])) {   <--------- line 10
>   $_POST['exact'] == false;
> }

Reverse the logic of isset().  

if (isset($_POST['exact'])) {
  $_POST['exact'] == TRUE;
}

If a variable is genuinely not set, it will produce the warning or
notice you are seeing.  There are a few ways to circumvent that: lower
your error reporting level, or quiet the error with @, or reverse the
logic so the error doesn't exist.  I prefer the last method as I
always use full error reporting during development.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux