// This will determine if the DB conection was successful.... if(connectMySQL($host,$user,$pass,$db) != FALSE) { // If its successful.... echo('Good to go!'); } else { // If not, then halt the script but not before we let the user know. echo('We got some problems!'); die(); } //////// // // // // // Put your content here! // // // // ////////
// Put your functions at the bottom. function conntectMySQL($host,$user,$pass,$db) { // This function combines the MySQL connect and DB select functions built-into php. $link = mysql_connect($host, $user, $pass); if(isset($link)) { $db_sel = mysql_select_db($db); if(isset($db_sel)) { return $db_sel; } else { return FALSE; } } else { return FALSE; } }
mysql_close(); // ALWYAS ALWAYS ALWAYS RUN THIS AT THE END OF THE SCRIPT. ?>
Last edited by Danny[MLWA]; June 23 '09 at 06:08 PM.