Functions and SESSION variables
Posted: Tue Apr 26, 2011 4:15 am
Hi Guys,
I have a page that looks similar to this:
Within that is a function to check for errors:
On Some machines I get frequent timeouts, but on others I don't, so I have added a few rudimentary timers around the different 'Query' pages. What I was wondering is if I add the results of these timers to $SESSION variables just after I create them, can I read those variables into the error functions, thus giving me a message telling me how long each section took, but more importantly I will be able to tell which one didn't complete, giving me a better idea of where the problem query is.
I have a page that looks similar to this:
Code: Select all
<?php
//cs.php
ob_start();
session_name('TS_Test');
session_start();
// Check for PHP Errors
include('error.php');
//RUN MySQL QUERIES
include ('Query1.php');
include ('Query2.php');
include ('Query3.php');
include ('Query4.php');
//Display the results
include ('Query1res.php');
include ('Query2res.php');
include ('Query3res.php');
include ('Query4res.php');
?>
Code: Select all
<?php
//error.php
register_shutdown_function('fatalErrorShutdownHandler');
function fatalErrorShutdownHandler()
{
$error = error_get_last();
if ($error['type'] === E_ERROR) {
// fatal error
while (ob_get_level()) ob_end_clean();
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
header('refresh: 30; url=cs.php');
}
print "ERROR TYPE = ".$error['type'];
}
}
// now, run everything else prepared to handle errors gracefully
function customError($errno, $errstr)
{
header( 'Location: error3.php' ) ;
die();
}
set_error_handler("customError");
?>