I got a “big” Facebook-application coming up. It is programmed in php using mysql (and the mysql_-class, not PDO…I know, I know). As I am close to an open beta, I’d like to keep track of any mysql-errors. I have a good host and I know that the script never looses connection to the database, so I thought I could store this in a table.
I’d like to keep track of the query doing failing (not a problem), but I’d also like to know what line and file this happened in. I’ve seen __LINE__ in a few scripts, but I never figured out how to use it.
My base simply looks like this:
$query = 'SELECT * ...';
$result = mysql_do_query($query);
function mysql_do_query ($q) {
[...]
}
My real question is; is it possible to log where the function mysql_do_query was called from? What line etc. Or is there another way to do this? Try and exceptions, perhaps?
You can use magic constants, or debug_backtrace, or write your own error handler.