Page 1 of 1

Line number reference

Posted: Tue Oct 14, 2008 5:41 pm
by w35z0r
Hello,
I was writting or die statements for my mysql statements and I was wondering if there was a way I could reference the line they occurred on without hard coding it in. Basically like when PHP returns and error and tells you what line its on.
Right now, I basically give a vauge descritpion of the statement that failed along with the mysql_error() function.
Example:

Code: Select all

 
mysql_query("UPDATE eo_tbl02 SET blendsWW = CONCAT(blendsWW, '$appendLink') WHERE productNumber='$pn'") or die("died while appending a bww, " . mysql_error()); 
 
This does the job well enough, but I think it'd be sweet if I could say what line as well.
Any thoughts?

--W

Re: Line number reference

Posted: Tue Oct 14, 2008 6:58 pm
by yacahuma
You should not use "or die" statement in production code. I dont think you want a user to see a big die when half you page has been generated already.

Re: Line number reference

Posted: Wed Oct 15, 2008 1:37 am
by jmut
__LINE__ constant might be of interested
debug_backtrace(), array_shift() etc.