-
-
Save waaronking/82c81f4f0ca2e0b1cf16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dbConnect($sql_hostName, $sql_Username, $sql_Password, $dbName = '') { | |
$server = $sql_hostName; | |
$name = $dbName; | |
$username = $sql_Username; | |
$password = $sql_Password; | |
$dsn = 'mysql:host='.$server.';dbname='.$name; | |
try { | |
$db = new PDO($dsn, $username, $password); | |
return $db; | |
} catch (PDOException $e) { | |
$error_message = $e->getMessage(); | |
include('database_error.php'); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment