While shared hosting is adequate for a lot of purposes, one annoyance is that they don't normally provide access to Apache error logs.
So, what you can then do, is simply create your own error logs for certain pages:
PHP Code:
<?php
error_reporting(0); // Turns off all error reporting.
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
$dt = date('Y-m-d H:i:s (T)');
// define an assoc array of error string
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
);
// set of errors for which a var trace will be saved.
$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
$err = "<errorentry>\n";
$err .= "\t<datetime>" .$dt. "</datetime>\n";
$err .= "\t<errornum>" .$errno. "</errornum>\n";
$err .= "\t<errortype>" .$errortype[$errno]. "</errortype>\n";
$err .= "\t<errormsg>" .$errmsg. "</errormsg>\n";
$err .= "\t<scriptname>" .$filename. "</scriptname>\n";
$err .= "\t<scriptlinenum>" .$linenum. "</scriptlinenum>\n";
if (in_array($errno, $user_errors)) {
$err .= "\t<vartrace>" .wddx_serialize_value($vars, 'Variables'). "</vartrace>\n";
}
$err .= "</errorentry>\n\n";
// save to the error log file, and e-mail me if there is a critical user error.
error_log($err, 3, 'error_log.log');
if ($errno == E_USER_ERROR) {
mail('you@address.com', 'Critical User Error', $err);
}
}
$new_error_handler = set_error_handler('userErrorHandler');
Save this code into a PHP file, upload it to your server and then include it into the page that is causing you problems (using the include() method).
What it'll do is to log any errors the PHP script creates into a file called error_log.log in the same directory.
You can also set your mail at the bottom of the script, so that it mails you in the event of a critical user error (or any error if you so desire).
I can't claim credit for the code. I found it here: http://www.hotscripts.com/blog/php-e...-file-archive/
Not sure if this will help you solve the problem, but should bring you a step forward at least.
Bookmarks