daydreamer Posted January 5, 2011 Share Posted January 5, 2011 I am currently using my own error handler so i can log all mysql errors into a mysql table: mysql_query('select data from table')or trigger_error(mysql_error(),256); If there's an error i need to know the line number where the mysql_query function was called. Is it possible to instead use this code: mysql_query('select data from table'); but somehow transparently log a mysql error and the line number if there is an error in the query? thanks Quote Link to comment https://forums.phpfreaks.com/topic/223496-clean-alternative-to-mysql_queryor-trigger_errormysql_error256/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2011 Share Posted January 5, 2011 http://www.php.net/manual/en/language.constants.predefined.php Quote Link to comment https://forums.phpfreaks.com/topic/223496-clean-alternative-to-mysql_queryor-trigger_errormysql_error256/#findComment-1155271 Share on other sites More sharing options...
daydreamer Posted January 5, 2011 Author Share Posted January 5, 2011 That page is helpful, i am aware of __LINE__, but the problem is I would need to know the line number where the function was called without passing __LINE__ as a argument. e.g. function mysql_query(){//override mysql_query mysql_query()or error_function(error_code,error_string,line_number); } mysql_query(); //<<< need to log this line number Quote Link to comment https://forums.phpfreaks.com/topic/223496-clean-alternative-to-mysql_queryor-trigger_errormysql_error256/#findComment-1155285 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2011 Share Posted January 5, 2011 debug_backtrace Quote Link to comment https://forums.phpfreaks.com/topic/223496-clean-alternative-to-mysql_queryor-trigger_errormysql_error256/#findComment-1155287 Share on other sites More sharing options...
daydreamer Posted January 5, 2011 Author Share Posted January 5, 2011 thats what i need, cheers Quote Link to comment https://forums.phpfreaks.com/topic/223496-clean-alternative-to-mysql_queryor-trigger_errormysql_error256/#findComment-1155294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.