Jump to content


Photo

To a FILE


  • Please log in to reply
2 replies to this topic

#1 bach

bach
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 21 May 2006 - 12:22 PM

Hello,

I would like to create a function/class (not sure which one appropriate) to log errors to a file.

To start with I would like to create a 'errorlog.txt' file where every mysql error message will be writen so I would be able to check the error log to see if anyone has been having issues login into database, etc.

Now I have the mysql error being displayed as part of my connection but I do not want the user to see this message.

So I would need to store that into a file instead I have no idea on this anyone able to help ?

Bach.

#2 eves

eves
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 21 May 2006 - 01:22 PM

wrap your sql query in a function and use this in all your queries
inside the function, perform the query, then test if there were any errors then log them


function db_query($qry)
{
    $result = @mysql_query($qry);
    if (mysql_errno() > 0)
    {
        // log error to file here
        // and/or perform some error handling
        // you can be creative on this part but be wary of some overheads
    }
    
        return $result;    
    
}


#3 bach

bach
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 21 May 2006 - 02:36 PM



Thanks for yor reply,

How would I go about writing the log to the file?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users