Jump to content

Where was the error?


LLLLLLL

Recommended Posts

OK, I thought I understood the error logging settings, but I don't quite understand. Trying to troubleshoot another friend's site, a page had a fatal error so it didn't load. The browser returned a "page not found" type of error. We enabled the log and found the issue and corrected it.

 

However, on my own machine, I tried to attempt this same bad behavior and I always see the error:

 

Fatal error: Call to undefined function foo() in /(path)/header.php on line 4

 

Why would my server show the error, but his server treated the page as if it did not exist? For the record, the entire page had this content

 

<?php
include( 'includes/header.php' );
?>

 

The error is caused because header.php calls a function that hasn't been defined. I'm just wondering why there is a difference of error handling.

Link to comment
Share on other sites

It has to do with the differences between the way the two servers are setup to handle the error.

 

On a Production server you don't want to showendusers the true error otherwise it can help hackers and kiddiescripters on your dirs structure, filenames, naming conventions, possible software you are running, etc...  so they can break in to your site.

 

On a Development server you turn all the error checking on so you can see where you have a problem.

Link to comment
Share on other sites

Well even the web host is unsure how they get this type of error to show a 500 error:

 

The website encountered an error while retrieving http://somesite/intentionalbadpage. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this web page later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

 

I like this type of error handling, but don't know how to get it set up!

Link to comment
Share on other sites

You need to configure PHP so the settings error_reporting is set to E_ALL and display_errors is set to On within the php.ini

 

You can also enable these settings within your scripts(s) using

error_reporting(E_ALL);
ini_set('display_errors', 1);

Link to comment
Share on other sites

But this just suppresses the errors, it doesn't cause a browser 500 error. That's the ultimate mystery I'm trying to solve.

It does not suppress the error messages. It will display the errors during run time.

 

When display_errors is not enabled (this is the setting which display the errors) you will either get a 500 Internal Error Message or a blank screen. When an error occurs they will be logged to the servers error log.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.