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

From: Date: Mon, 10 Aug 2009 00:00:43 +0000
Subject: Re: reason for a "Notice:.." on one site but not another? (Same code.)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-296534@lists.php.net to get a copy of this message
> 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

« previous php.general (#296534) next »