Re: reason for a "Notice:.." on one site but not another? (Same code.)

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

 



> But on another site it still works, but gives this error:
> Notice: Undefined index: UserWishesDateRange in
> /home/vs/site/phvs/bl/7solarsecrets/admin/trackingcode.html on line 79
>
> I assume that is because the error display settings are set to a more
> rigorous level in this latter site.
> Is this correct?

It's either the 'error_reporting' configuration directive that's
different between the two servers, or 'display_errors', or both.

On one server the E_NOTICE bit-field is set in 'error_reporting', and
it sounds like 'display_errors' is also set (unless you're seeing that
notice in a log file).

On the other server, one or the other of those things is not set (or
both of them aren't).

You can use call ini_get('error_reporting') and
ini_get('display_errors'), to see what they're set to on each server.
Or just create a small page that only calls phpinfo(), to see all
configuration directives.

Here's the write-up of the directives (one is right below the other):

http://us3.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

As others have pointed out, it's a good idea to call isset() on a
POST-variable before trying to get at its value. This will avoid a
notice being thrown.

Lately I've stopped touching $_POST directly and started using
filter_input() instead; this also avoids the problem and provides
several other benefits:

http://us2.php.net/manual/en/function.filter-input.php

The filter_* functions are only available in core since 5.2.0, though.

Ben

-- 
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