...

View Full Version : ignoring error warnings



esthera
02-05-2007, 05:24 PM
I have the following error function:

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
// put your error in file.
$filename = 'error.txt';
global $sql;
$errsql=$sql;
$errorstr = $errno.$errstr.$errfile.$errline."\n\r".$errsql. "\n\r\n\r\n\r";
//echo $errrorstr;
$handle = fopen($filename, 'a');
fwrite($handle, $errorstr);
fclose($handle);
}

How can I get this to not store warnings such as 8Undefined index: HTTP_REFERER ?

GJay
02-05-2007, 07:52 PM
undefined index is a E_NOTICE-level error, so setting error-reporting to
error_reporting(E_ALL ^ E_NOTICE);
will prevent it from being reported.

take a look at http://php.net/error-reporting for more details

esthera
02-06-2007, 05:19 AM
instead of error_reporting(0); -- I don't want any errors to show but my error handler picks them up and saves them.
i don't want to save any warnings

how do I do this?

_Aerospace_Eng_
02-06-2007, 05:23 AM
Did you even try what GJay suggested? error_reporting(0) is not what he suggested.

CFMaBiSmAd
02-06-2007, 05:39 AM
For variables that may or may not exist, write code using the isset() function to avoid the generation of the error in the first place, instead of messing around with the error reporting or error handler after the error has already been generated. Your code will actually run faster by doing this as well.

marek_mar
02-06-2007, 10:12 AM
A custom error handler in PHP will get to handle all errors it can - it doesn't use the error_reporting setting to see if it should handle an error or not.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum