No longer need to put the database server connection info in each page
This commit is contained in:
15
var/www/db_connection.php
Normal file
15
var/www/db_connection.php
Normal 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();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user