AW: Need help with HTML form errors

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

 



Good morning Nagendra,

Nagendra wrote:
> ...
> The above code is giving me the following errors:

> <br /> <b>Notice</b>:  Undefined variable: filter in
> <b>C:\wamp\www\5_Final\index.php</b> on line <b>228</b><br />

> Notice: Undifined Variable: filterfield in c:\wamp\www\5_final\index.php
on
> line 233 > Type
> ...

The error occurs because you did not initialize the $filter and $filterfield

variables before using them; this does not indicate an error because these 
variables will most likely not be set when the form is displayed initially.

You have multiple options to avoid this error:

1) Change the error_reporting setting in your php.ini or set 
"error_reporting (E_ALL & ~(E_STRICT|E_NOTICE));" inside your php script.
>> This disables PHP notices but could make debugging a bit more
complicated.

2) Initialize the variables before using them:
[CODE]
// I assume the variables will be passed by the form, that's why they are in
the 
// superglobal $_POST array; if the variable has been passed (isset(...),
use it,
// otherwise initialize with false

$filter = isset($_POST["filter"]) ? $_POST["filter"] : false;
$filterfield = isset($_POST["filterfield"]) ? $_POST["filterfield"] : false;
[/CODE]

HTH!

Regards,

Sascha


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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux