Geezzzeee - getting nowhere fast here.
I have set up the error handler, and it now definately works - i have tested it, but just in case anyone wants to check:
// Decide what errors to report:
error_reporting (E_ERROR | E_USER_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_WARNING | E_NOTICE);
// Webmaster email and error page url:
$Wmemail = 'xxx@xxxxx.com';
$ErrorPage = 'http://www.yoursite.com/error.html';
// This function will check the error type:
function MailErrorHandler($errno, $errstr, $errfile='?', $errline= '?') {
global $Wmemail, $ErrorPage;
if (($errno & error_reporting()) == 0)
return;
$err = '';
switch($errno) {
case E_ERROR: $err = 'FATAL'; break;
case E_USER_ERROR: $err = 'FATAL'; break;
case E_CORE_ERROR: $err = 'FATAL'; break;
case E_COMPILE_ERROR: $err = 'FATAL'; break;
case E_WARNING: $err = 'ERROR'; break;
case E_NOTICE: return;
}
// Send the error details via email:
mail($Wmemail,
"PHP: $errfile, $errline",
"$errfile, Line $errlinen$err($errno)n$errstr");
// Redirect to the error page:
print "<meta http-equiv=\"refresh\" content=\"0;url=http://error page\">";
die();
}
set_error_handler('MailErrorHandler');
Now this handles all errors, but ones like this:
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft JET Database Engine
Description: Not a valid password.' in c:\Inetpub\wwwroot\script.php:22 Stack trace: #0 c:\Inetpub\wwwroot\script.php(22): com->Open('Provider=Micros...') #1 c:\Inetpub\wwwroot\script.php(18): require('c:\Inetpub\wwwr...') #2 {main} thrown in c:\Inetpub\wwwroot\script.php on line 22
Here is the code i use to connect:
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Jet OLEDB:Database Password=xxxxxxxxx;Data Source=D:\\sheet1.mdb;");
if ($conn->State == 1) { } else {die("TEST CONNECTION FAILED"); }
Now, problem is, if the connection does not connect, php does not even get to the next line if ($con->State == 1 etc...
Any ideas on how i can either:
a) handle the error in a different way or
b) properly test the OLEDB connection to stop the error in the first place....
Yours,
::mega confused:: ChaosT