Re: [PHP] when using die(), how can i get the line number that errored?

2001-01-30 Thread Richard Lynch

function errtrapper($file, $line){
echo "In $file on line $lineBR\n";
#current body here.
}

die(errtrapper(__FILE__, __LINE__));


--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: "Noah Spitzer-Williams" [EMAIL PROTECTED]
Newsgroups: php.general
Sent: Monday, January 29, 2001 6:59 PM
Subject: [PHP] when using die(), how can i get the line number that errored?


 here's my code:

 $res = mysql_query($badsqlstatement) or die(errtrapper());

 inside errtrapper(), is there a way to find out what line this error
 occurred?

 thanks!!

 - Noah



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] when using die(), how can i get the line number that errored?

2001-01-30 Thread Neil Kimber

Rather than use die() why not use trigger_error() and have an error_handler
registered with the parser.
Firstly, create an error handler and register it - I use something like the
following:


function myErrorHandler($errno, $errstr, $errfile, $errline)
{
$locStrMessage = $errfile . " " . $errline . " " . $errno . " : " .
$errstr;
error_log($locStrMessage  . "\r\n",3,'debug/debug.log');
}

Register this in your autoprepend file using:

set_error_handler("myErrorHandler");

Now, whenever you get an error it gets logged to your debug file with the
file and line number. You can 'generate' errors using trigger_error() and
pass it a string of information. You can use this method to catch absolute
bad bugs and also to dump useful debug information.

This is quiet an elementary implementation of good error handling, you can
take this and extend it into quite a useful system for tracking bugs. You
could add system flags for turning debug on and off, alter levels of
debugging etc...

regards,
Neil

p.s. assert() is cool too.


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]]
Sent: 30 January 2001 08:50
To: [EMAIL PROTECTED]
Subject: Re: [PHP] when using die(), how can i get the line number that
errored?


function errtrapper($file, $line){
echo "In $file on line $lineBR\n";
#current body here.
}

die(errtrapper(__FILE__, __LINE__));


--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: "Noah Spitzer-Williams" [EMAIL PROTECTED]
Newsgroups: php.general
Sent: Monday, January 29, 2001 6:59 PM
Subject: [PHP] when using die(), how can i get the line number that errored?


 here's my code:

 $res = mysql_query($badsqlstatement) or die(errtrapper());

 inside errtrapper(), is there a way to find out what line this error
 occurred?

 thanks!!

 - Noah



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] when using die(), how can i get the line number that errored?

2001-01-29 Thread Noah Spitzer-Williams

here's my code:

$res = mysql_query($badsqlstatement) or die(errtrapper());

inside errtrapper(), is there a way to find out what line this error
occurred?

thanks!!

- Noah



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] when using die(), how can i get the line number that errored?

2001-01-29 Thread David Harrison

print __LINE__

Will print the line number (as per
http://www.php.net/manual/en/language.constants.php). 

--dave 

 -Original Message-
 From: Noah Spitzer-Williams [mailto:[EMAIL PROTECTED]]
 Sent: Monday, 29 January 2001 7:21 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] when using die(), how can i get the line number that
 errored?
 
 
 here's my code:
 
 $res = mysql_query($badsqlstatement) or die(errtrapper());
 
 inside errtrapper(), is there a way to find out what line this error
 occurred?
 
 thanks!!
 
 - Noah
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: 
 [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] when using die(), how can i get the line number that errored?

2001-01-29 Thread Maxim Maletsky

$res = mysql_query($badsqlstatement) or die(errtrapper().' at line
(B'.__LINE__.'/B)');

Cheers,
Maxim Maletsky

-Original Message-
From: Noah Spitzer-Williams [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 29, 2001 6:21 AM
To: [EMAIL PROTECTED]
Subject: [PHP] when using die(), how can i get the line number that
errored?


here's my code:

$res = mysql_query($badsqlstatement) or die(errtrapper());

inside errtrapper(), is there a way to find out what line this error
occurred?

thanks!!

- Noah



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]