error handling

Enable PHP ADODB handling

Snippet

By default, PHP's ADODB library will not give full error messages on pconnect, or route to an error handler. The error handler has to be enabled.

<?php
 
// pass any error messages triggered to error handler
error_reporting(E_ALL); 
 
include('adodb-errorhandler.inc.php');
include('adodb.inc.php');
 
// suppress error messages for the connection
ini_set("display_errors", "0");
try {
  $mydb = &ADONewConnection('mysql');
  $mydb->PConnect('dbhost','dbuser','dbpass','dbname');
} catch (exception $e) {
  // unable to connect to the DB (usually too many connections), redirect away                                                                                            
  header('Location: /error.html');
  exit();
}