Thursday, January 31, 2008

Logging PHPnuke Database Connection Failures

Find the db/db.php file in your PHPnuke installation and insert the error_log line.

if(!$db->db_connect_id) { die(”<br><br><center><img src=images/logo.gif><br><br><b>There seems to be a problem with the $dbtype server, sorry for the inconvenience.<br><br>We should be back shortly.</center></b>”);
}

Now the last lines of the db/db.php file should look like this. The error_log simply logs the errors into /home/foo-joe/logs/db_log, you should change this to reflect your directory structure.

if(!$db->db_connect_id) {
error_log(”[”.date(“D M d Y h:iA”).”] Failed to serve request for page ‘”. $_SERVER[‘REQUEST_URI’].”’ from ‘”.$_SERVER[‘REMOTE_ADDR’].”’ using browser ‘”. $_SERVER[‘HTTP_USER_AGENT’].”’\n”,3,”/home/foo-joe/logs/db_log”); die(”“<br><br><center><img src=images/logo.gif><br><br><b>There seems to be a problem with the $dbtype server, sorry for the inconvenience.<br><br>We should be back shortly.</center></b>”);
}

Refer to error_log PHP manual page for more information and PHPnuke documentation on error logging and database calls, Please note this is for debugging purpose only.

No comments:

Post a Comment

You can leave a comment here using your Google account, OpenID or as an anonymous user.

Popular Posts