Thursday, March 1, 2012

Exception handling in php when using mysql statements.

Exception handling in php when using mysql statements.

try { 
                        if(!@mysql_connect($db['hostname'],$db['username'],$db['password'])){
                            throw new Exception("Database connection failed. Please correct it and continue.");
                        } 
                    } 
                    catch(exception $e) {
                        echo $e->getMessage();
                        exit;
                    }

No comments:

Post a Comment