AW: Need help with HTML form errors

"Sascha Meyer" <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <007001cb1b57$85af8b50$910ea1f0$@de>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.