Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Catch database connection exception

Mon Oct 27, 2008 11:53 pm

Code:

<?php

   try
{
      
$conn = mysql_connect("localhost","username","password");
         if (!
$conn) {
            
throw new Exception("Could not connect!");
        }
   }
   
catch (Exception $e) {
      echo
"Error (File: ".getFile().", line ".$e->getLine()."): ".$e->getMessage();
   }

?>




Post a reply
  Related Posts  to : Catch database connection exception
 exception handling try and catch in Python     -  
 database connection     -  
 exceptions catch by a catch clause     -  
 database connection pooling problem     -  
 Out of Bounds exception     -  
 Exception is not clear     -  
 Exception handling     -  
 Multiple Exception Catching     -  
 Define your own exception class     -  
 String Too Long Exception     -  

Topic Tags

PHP Exceptions, PHP Database