On 10 October 2003 21:28, James Johnson wrote: > Hi, > > I'm getting so frustrated with this..... > > I have put some error trapping code in my site with the > following code (an > included file): > > <?php > ob_start(); > error_reporting(E_ALL); > set_error_handler('pc_error_handler'); > function pc_error_handler($errno, $error, $file, $line, $context) { > $message = "[ERROR][$errno][$error][$file:$line]"; > error_log($message); echo $message; > } > > > > > I have a page that hits the database to display the records. > One of the > columns is 'startDate'. I format this for display like this: > > <td valign="top"><?php echo > date('m/d/Y',strtotime($row_GetAds['startDate'])); ?></td> > > The page returns the following error: > > [ERROR][8][Undefined index: > startDate][/home/.paco/campuscb/campuscorkboard.com/search_job > s.php:319][ERR OR][8][strtotime() called with empty time > parameter][/home/.paco/campuscb/campuscorkboard.com/search_job > s.php:319]10/1 0/2003 > > If I comment out the error_reporting include file, the page > renders fine. I > have checked the DB and the startDate column has a valid date in it.
I'd bet this is solely to do with your error_reporting setting -- what is it when you have the error-trapping include commented out? Odds on it's E_ALL ^ E_NOTICE, and the two errors in question are NOTICE-level messages (as evidenced by the [8] in each message) -- so you see them when your error handler has control, but not when it doesn't. Try putting the error_reporting(E_ALL) call in your main script, commenting out the include, and seeing if you now get standard PHP notices about these two errors. Something else to note is that the setting of error_reporting has absolutely no effect on when your error_handler is called -- it will be called every time there is an event that *could* generate an error message. It's up to your error_handler to decide, on each occasion, whether it *should* issue a message -- thus, if you want it to observe the error_reporting setting, you have to test the value of the $errno parameter (which is actually the error *level* of the error, not an individual error number) against the current setting of error_reporting() (you have to fetch the result of error_reporting() every time, since it will be zero if the context triggering the error is affected by an @ operator, allowing you to ignore that particular error if you want to). Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php