Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

PHP Error Settings

I have the following set in WHM php settings.  Yet in my application it's still echoing out notices.  There is no error reporting set on the page itself.

Am I doing something wrong?
Untitled-1.jpg
Avatar of James Bilous
James Bilous
Flag of United States of America image

Seems like that should be enough, but have you tried setting "display_errors = Off" in the same file?
1. Can you provide examples of what's being echoed out?

2. Did you restart the web server after making the change?

3. If you set error_reporting to 0 (zero) and restart the web server, do you still get notices?

A side note - any notices or warnings should really be addressed instead of suppressed. Suppressing notices/errors can lead to other unwanted and hard-to-debug behavior later on because they're referring to code that has some kind of problem.
Agree with @gr8gonzo (usually do) about remediating whatever is causing a Notice.  Turning off the Notices is like putting black electrical tape over the warning light on your dashboard.  It makes the symptom go away, but doesn't really help with the problem.

You might want to use phpinfo() to see what error_reporting is really in effect.  It will be more reliable than looking at any source document.  Because PHP has about a million configuration options and several places that the options can be invoked, we always have to be on the lookout for conflicting or superseding cascades of options.
Avatar of Nathan Riley

ASKER

Yeah, not sure on the best way to fix.  I tracked down and the issue is that areas where I have the following:

if($_GET['listID'] == '75'){ echo 'selected';}

Open in new window


It throws an undefined error on that get variable.  The only way I found to fix was to do:
if(isset($_GET['listID'])){if($_GET['listID'] == '75'){ echo 'selected';};}

Open in new window


Is there a better way to do this, seems like a lot of extra unnecessary code?
Looks like the variable listID is null in the parameters of the get request that your server is responding to which is why when you try to $_GET it out of the request you are being warned about it not being there. You can't get much more succinct about checking for null, but you could figure out why it is null in the first place to prevent errors being thrown.

Your original question seems to be about your WHM settings and suppressing errors, but as others suggest you might be better off just fixing the error in the first place. Why is the variable null? Is a form element not correctly setting the listID as you would expect?
Well it's null because it's only set if someone has clicked a certain list then the drop down sees the set variable and sets it selected. So it being null is not a bad setting just means they are on the view all.
When you say the "drop down sees the set variable and sets it selected" are you talking about some sort of javascript? Is this something you developed or a plugin? If its something you have implemented, I would give whatever variable is in charge of maintaining the dropdown state a default value so it is not passing NULL. Using a variable that is NULL in php is going to trigger interpreter errors like the ones you are seeing.
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with James that ternary statements:
(condition ? value if true : value if false)

...are harder to read. Use them sparingly, and if possible, in groups of statements with comments and spacing so that readers can see the context and use that to read the rest of the statements. For example:

Okay:
$listID = (isset($_GET["listID"]) ? intval($_GET["listID"]) : null);
$otherID = (isset($_GET["otherID"]) ? intval($_GET["otherID"]) : null);
$fooID = (isset($_GET["fooID"]) ? intval($_GET["fooID"]) : null);
if($listID == 123)...

Open in new window


Better:
// Sanitize GET parameters and set defaults
$listID  = (isset($_GET["listID"])  ? intval($_GET["listID"])  : null);
$otherID = (isset($_GET["otherID"]) ? intval($_GET["otherID"]) : null);
$fooID   = (isset($_GET["fooID"])   ? intval($_GET["fooID"])   : null);

if($listID == 123)...

Open in new window