tags:

views:

51

answers:

2
+1  Q: 

php error tracking

hi to all experts,

i am using php and mysql for my projects with pear package.

i want to track bugs in my programs .

is there any way to track a bug in pear package or php5.

suppose in my program any error or warning is generate then i want to track this error and

store into database.

any one have idea about it.

thanks in advance.

A: 

If you want to find bugs faster, you should consider using xdebug. It provides more output on errors and allows you to debug the application step-by-step.

If you need to log exceptions, you can use some logger, like Zend_Log, to write logs with specific application data. You can even specify message importance level to leave out debug data on production systems.

Also, I would recommend using Firebug together with Firephp. This way you can get debug data easily without using print_r and the likes.

Igor Zinov'yev
+3  A: 

Do not store errors in the database. many errors are database related itself. what would you do with it?

PHP already have everything you want. just turn on log_errors ini directive and, optionally, error_log one to specify certain log file instead of placing PHP errors in the web-server's log file

Also you may find useful a trigger_error() function which could bring a custom message to the standard error output, e.g

mysql_error($sql);
if(!$sql) trigger_error(mysql_error()." in ".$sql);
Col. Shrapnel
but i want to store error detail in database.
Sanjay
Then parse that log file every N hours and load it into the database for later error reporting.
CaseySoftware
I agree with Col. Shrapnel here, you don't want to keep track of errors that happened in an application by means of that same application.
Igor Zinov'yev
@Sanjay what for?
Col. Shrapnel