Error code recording

He has: 183 posts

Joined: Nov 2003

Hi,

Just an idea that i had. Is it possable to record the error code and the file in question plus the line of the error and save it in to a database?

Regrads

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

What type of error? for what?

For the service I program, every page has logging, not to a database, but to flat text files, stored in folders of the username (or "_NON_USER_") and then in that folder, named in the format YYYY-MM-DD_HH-MM-SS.log so they can be sorted

Inside, the first thing it logs is server information i need (refering page, url requested, ip address, browser type, etc).

Then each line of data contains a line number, file name, and whatever i choose to output (being a variable value, or a comment to let me know where program flow went)

my functions for doing database calls include code to log all SQL as it is given to the server right before it does it and the status right afterwards.

this really makes a large program (my main file, not counting any included modules, is over 750 lines long) a lot easier to follow the flow when something goes wrong.

If you are using PHP, you can use the following variables to help log the info:

__LINE__ is the current line number (ie. echo "You are on line #" . __LINE__ . "\n"; )
__FILE__ is the current file (helpful when you have several included files)

note, if you do like me, and have the debug set up in a function, you need to PASS these values to the function, else they will always show the line number/filename of the line in the function.

I do things like the following to see what $myArray['test'] is:

debugOut (__FILE__,__LINE__,"myArray[test]=" . $myArray['test']);

Note that it is also helpful to write a function to dump the values of an entire array (similiar to doing a print_r($array) )

I will have to clean up my debugging module and post it here some day

-Greg

He has: 183 posts

Joined: Nov 2003

Hi, Thanks for the that. I want to record any errors which the user may find for example some page on my site my not have "Dont show" if recordset is empty. So if the user has deleted data then returns to the page which needs the data, it will show a big ever and i will need to fix the problem. but if no body tells me, then its hard for me to fix.

So i'm looking for something that will record in to a database, txt file anything.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.