How to display line number where error occurs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

How to display line number where error occurs

Post by eshban »

Hello,

I am trying to writing a code i.e if query dies then admin will got an email with the following information. I have shown the following information in an error email

Complete URL :
Date and Time:
Logged In User name:
User Type:
Query that dies:

Everything is going well.

Now i want to display the LINE NUMBER of the code where error occurs.

I am unable to do this. Kindly help me in this regard. It takes my lot of time

Regards,
Eshban
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to display line number where error occurs

Post by requinix »

The magic constant __LINE__ is the line number it is on.

Code: Select all

<?php
 
// blah
// blah
// blah
mysql_query($query) or die(query_error($query, __LINE__));
query_error takes a query and a line number and sends the email.
Post Reply