20 lines
528 B
PHP
20 lines
528 B
PHP
<?php
|
|
// db_connection_function.php
|
|
|
|
function db_connect(){
|
|
require_once("db_connection_data.php");
|
|
// db_server = "mysql:dbname=testdb;host:localhost";
|
|
$db_server = "$db_engine:dbname=$db_name;host=$db_host";
|
|
try {
|
|
$dbh = new PDO ($db_server, $db_user, $db_password);
|
|
echo "<p>DB Connection succesfull established!</p>";
|
|
return $dbh;
|
|
} catch (PDOException $e){
|
|
//echo "Could not connect to DB!<br> ";
|
|
die("More:".$e->getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
// Test:
|
|
// db_connect();
|