No longer need to put the database server connection info in each page

This commit is contained in:
William Miceli
2019-12-03 04:38:53 -05:00
parent 40debb217c
commit 52c4f35350
3 changed files with 17 additions and 5 deletions

15
var/www/db_connection.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
$db_server = "localhost";
$db_name = "friendBook";
$db_username = "web";
$db_password = "Password456";
try{
$db_connection = new PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
$db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
echo "PDOException: ".$e->getMessage();
}catch(Exception $e){
echo "Exception: ".$e->getMessage();
}
?>