Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-05-2007, 05:24 PM   PM User | #1
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,431
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
ignoring error warnings

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 ?
esthera is offline   Reply With Quote
Old 02-05-2007, 07:52 PM   PM User | #2
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
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
__________________
My thoughts on some things: http://codemeetsmusic.com
And my scrapbook of cool things: http://gjones.tumblr.com
GJay is offline   Reply With Quote
Old 02-06-2007, 05:19 AM   PM User | #3
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,431
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
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?
esthera is offline   Reply With Quote
Old 02-06-2007, 05:23 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Did you even try what GJay suggested? error_reporting(0) is not what he suggested.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 02-06-2007, 05:39 AM   PM User | #5
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,714
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
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.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is online now   Reply With Quote
Old 02-06-2007, 10:12 AM   PM User | #6
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
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.
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:09 AM.


Advertisement
Log in to turn off these ads.