cheers,
I now have:
Code: Select all
<?php
session_name('slaveLocal');
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;
register_shutdown_function('fatalErrorShutdownHandler');
function fatalErrorShutdownHandler()
{
$error = error_get_last();
if ($error['type'] === E_ERROR) {
// fatal error
while (ob_get_level()) ob_end_clean(); // clean up output buffers
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error'); // be nice to computers, follow http standards
}
include('error.phtml'); // be nice to humans, show friendly error message
}
}
// now, run everything else prepared to handle errors gracefully
include('q2.php');
... rest of the script ...
error.phtml is copied from what you posted for the moment.
q2.php simply prints the word hello in order to stop it giving an error of it's own.
But when I run this I get:
[text]
Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3305) in C:\wamp\www\Local\slaves\CheckSlavesv8.php on line 202
Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\Local\slaves\CheckSlavesv8.php on line 202
Warning: mysql_query() expects parameter 2 to be resource, boolean given in C:\wamp\www\Local\slaves\CheckSlavesv8.php on line 203
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\wamp\www\Local\slaves\CheckSlavesv8.php on line 205
[/text]
But I thought that the newly added script would catch this and display error.phtml instead.