Re: Will not report errors what can I do
| From: | Robert Cummings | Date: | Fri, 05 Dec 2008 18:08:42 +0000 |
| Subject: | Re: Will not report errors what can I do | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-284184@lists.php.net to get a copy of this message | ||
On Fri, 2008-12-05 at 10:40 -0500, tedd wrote:
> At 3:19 PM +0000 12/5/08, ceo@l-i-e.com wrote:
> > > $result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));
> >>
> >> //==================== to show dB errors ======================
> >>
> >> function report($query, $line, $file)
> >> {
> >> echo($query . '<br>' .$line . '<br/>' . $file .
> >> '<br/>' .
> >> mysql_error());
> >> }
> >>
> >> This does two things: 1) It tells where the error took place
> >> (line/file); 2) and it provides a single place in my entire project to
> >> turn-off dB error reporting -- all I have to do is comment out a single
> >> line.
> >
> >I did this, briefly, but got tired of typing __LINE__, __FILE__ so much.
>
>
> That's what I call common code -- I type it once and after that it's
> all cut/paste.
>
> I have entire libraries of routines that I've used before -- I just
> cut/paste them into the new stuff as needed. Even many of the
> variable names remain the same so it becomes more a job of assembly
> more than typing.
I have to say... for what he's trying to achieve, I cheat and extract
the file and line number via debug_backtrace(). Indeed, it is annoying
to type the same thing over and over :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP