PHP Error Handler

zardiw

Perch
Lately, when there is an error in a PHP page, I get a totally blank page returned.......no errors are indicated/shown.

This is happening only recently........before, errors generated were shown on the web page.

Needless to say this makes debugging a tad difficult.

In the following script, the file is not found, But a totally blank page is rendered with nothing in it.

Partial Code Below:

Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//3.2">
<HTML>
<HEAD>
<TITLE>Amanda Import Shell Data</TITLE>
<META NAME="Generator" CONTENT="FlexSite 2.8">
<META NAME="Author" CONTENT="FlexSite 2.8">
</HEAD>
<BODY  TEXT="#000000" LINK="#0000ff" VLINK="#00ffaa" 
	ALINK="#576000"
	 BGCOLOR="#FFFF99" BISHOPRICS="FIXED" >
<?

function my_error_handler ($errno, $errstr, $errfile, $errline, $errcontent) {

    echo "<font color='red'><b>An Error Occured!</b></font><br>";
    echo "<b>Error Number:</b> $errno<br>";
    echo "<b>Error Description:</b> $errstr<br>";
    echo "<b>Error In File:</b> $errfile<br>";
    echo "<b>Error On Line:</b> $errline<br>";
}

set_error_handler("my_error_handler"); 


//==============================================

include "DDSpyCon.php";

$filename = "Shells1.csv";
$count = 0; 
$fd = fopen ($filename, "r") or die("Unable to open file!");

$ExpFilLine = fgets($fd);
$ExpFilLine = fgets($fd);
$ExpParts = explode(",", $ExpFilLine); 

$CurrSymb = $ExpParts[0];
print_r('First One -' . $CurrSymb);
 
With the upgrade in systems, perhaps there's a new php.ini that's hiding the errors? Try adding error_reporting (E_ALL) to see if you get the php errors; I suppose you might need to also disable your custom handler. Your sample script uses a short opening tag. Try using <?php instead.

Other than that, I don't know. Your script creates the expected errors on my local computer. I didn't try it on a live server.

Tim
 
Hey..Thanks for taking the trouble to check this out. I added php_option show errors on to my .htaccess but then I took that out again.

Errors are showing up now....

Btw. .What is E_ALL and where do you put it?......Thanks again.....z
 
I didn't add the code formatting so my text was unclear. Sorry for that. Add:

Code:
error_reporting (E_ALL);

at the top of your code to set error output to all....actually, you'll want that for only debugging. It will output all sorts of warnings, messages, and errors and clutter your page from a user's standpoint.

From the php help pages:
Code:
<?php

// Turn off all error reporting
error_reporting(0);  // or error_reporting(^E_ALL);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>
 
That doesn't seem to work for me. I wonder if there's any specific reason to not show any errors starting after the HSphere updates, because it seems pretty non-standard

edit:
.htaccess at the root with:

php_flag display_errors on
php_value error_reporting 1

works...
 
Has anyone been successful in getting error handling to work? I've tried creating a php.ini with error_reporting(E_ALL); I have tried adding a variety of settings in the .htaccess file with no luck.

I'm no php expert but I'm very frustrated that I can't get any errors to display!! It makes it very difficult to debug!

I have a test page which should generate an error at www.durranimedia.com/labels/test.php
and my php info page: www.durranimedia.com/labels/info.php.

Any help would be greatly appreciated!

I currently have the php.ini suggested from this post to which I'm replying in the labels directory.
 
Create a file like debug.php and include the page that errors out. You must be able to see the error this way and without having error display enabled on your website (that may reveal sensitive information).
 
Where do you have the error_reporting() statement? It should be at or near the top. Can you post your PHP code here or as a text file on your site so I can take a peek?

BTW, I have no troubles getting programming errors to show up...in fact errors are sort of my specialty! :D

Tim
 
Back
Top