From: Thijs Lensselink on
Quoting Mathijs van Veluw <mathijs.van.veluw(a)smscity.com>:

> Hello there,
>
> I have an shutdown function to catch fatal-errors etc..
> Now when there is an exit() somewhere i get an empty message from
> get_last_error().
> I want to know the location of this exit() or die().
>
> Is there a way to get the file and line-number from where the exit/die
> originated?
>
> Thx in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

I don't think this is possible in PHP. When exit(0); is called. PHP
execution stops. In the manual there is a small comment about exit
inside a register_shutdown_function

[snip]
Multiple calls to register_shutdown_function() can be made, and each
will be called in the same order as they were registered. If you call
exit() within one registered shutdown function, processing will stop
completely and no other registered shutdown functions will be called.
[/snip]
From: tedd on
At 9:23 AM +0200 7/16/08, Mathijs van Veluw wrote:
>Hello there,
>
>I have an shutdown function to catch fatal-errors etc..
>Now when there is an exit() somewhere i get an empty message from
>get_last_error().
>I want to know the location of this exit() or die().
>
>Is there a way to get the file and line-number from where the
>exit/die originated?
>
>Thx in advance.

Mathijs:

For MySQL failures I use:

$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));


function report($query, $line, $file)
{
echo($query . '<br>' .$line . '<br/>' . $file . '<br/>' .
mysql_error());
}

Perhaps you can modify that for your use.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From: tedd on
At 9:15 AM -0400 7/16/08, Eric Butera wrote:
>As an aside, if I were to see some jibberish about a query and line
>numbers when I click a link I'd leave that site. (And for the
>archives) It is a security vuln to show full file paths to an end
>user. If someone is tampering with your system we shouldn't give them
>any more information than they can already get.

It can certainly help you for debugging, but I agree, it's not for production.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From: tedd on
At 2:18 PM -0400 7/16/08, Eric Butera wrote:
>On Wed, Jul 16, 2008 at 1:53 PM, tedd <tedd.sperling(a)gmail.com> wrote:
>> At 9:15 AM -0400 7/16/08, Eric Butera wrote:
>>>
>>> As an aside, if I were to see some jibberish about a query and line
>>> numbers when I click a link I'd leave that site. (And for the
>>> archives) It is a security vuln to show full file paths to an end
>>> user. If someone is tampering with your system we shouldn't give them
>>> any more information than they can already get.
>>
>> It can certainly help you for debugging, but I agree, it's not for
>> production.
>>
>> tedd
>
>I register an error handler & a shutdown function on new features so
>that I can get error reports via email. I hate trying to sift thru
>logs and junk so I really need it in my face. Of course this is a
>performance hit as it actually has to send emails and parse errors,
>but after I haven't got any mails in a while I turn it off.

I don't really know how others debug, I work alone. But, I do all my
stuff online and use the following function:

function report($query, $line, $file)
{
echo($query . '<br>' .$line . '<br/>' . $file . '<br/>' .
mysql_error());
}

That gives me immediate notice of where the error occurred and what
the error was. When I take my code to production, I simply comment
out the echo().

I used to use a global to do that (show/not show errors), but
consider all my error stuff in is one file, it's easy enough to
comment out what I don't want to show.

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com