If there’s any improvements that can be made to the following script please let me know.
[php]
// Create URI for connecting to server
$dataSourceName = “mysql:host=$dbIPAddress;dbname=$dbName”;
// Create Server Connection Object
try {
$dbObject = new PDO($dataSourceName, $webServerUsername, $webServerPassword);
return $dbObject;
}
// If something breaks above, catch the thrown exception
// and hope some other program including this script outputs to the browser.
catch (PDOException $errorData) {
$errorMessage = $errorData ->getMessage();
$dbDebugMsg .= <<<DEBUG
Debug Message: Connection to $dbName @ $dbIPAddress has failed.
Details: $errorMessage