Weird yet Funny IpowerWeb bug!

Hi all,

On a live site, I’ve added

ini_set('display_errors',0);

at the top of my code, to hide any unexpected errors from the end user.

But this makes the things worse, as whenever there’s a fatal error, the output will be an Internal server error!

eg:

<?php
ini_set('display_errors',1);
crash_the_bogus_ipower(); # ;)
?>

output: Fatal error: Call to undefined function crash_the_bogus_ipower()

<?php
ini_set('display_errors',0);
crash_the_bogus_ipower(); # ;)
?>

0
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, cgiadmin@yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Any clues? I’ve contacted the support team but they are still ‘beating around the bush’ :frowning:

@Mod: Not sure if this is the right forum. Please move it, if it’s not.

Try this:


<?php
  ini_set('display_errors', true);
  error_reporting(0);           # http://php.net/manual/en/function.error-reporting.php

  crash_the_bogus_ipower(); # ;)
?>


Thanks for the reply.

I originally had that in my code. I’ve removed it while posting here, to get the focus on the root cause.

  • the answer : No effect.

From the Php Manual:

Note:

Although display_errors may be set at runtime (with ini_set()), it won’t have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

The way I handle errors is:



  # top level calling program
  define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
  error_reporting( LOCALHOST ? -1 : 0 );
  ini_set( 'display_errors', LOCALHOST ) ;  


This catches all errors during development and hopefully none appear on a live site;
Your forced error during development will be detected and should be eliminated.

Your forced error during development will be detected and should be eliminated.

Initially, I face this issue when I inadvertently set a wrong entry in the DB (of a forum), which resulted in a fatal error inside a loop that generates an xml file (Fatal error : call to function appendChild() from a non object)

Narrowing down, I realised that, this happens only when there’s ini_set(‘display_errors’,0); and a fatal error.