-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.php
33 lines (24 loc) · 914 Bytes
/
db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/*
Project: Home Inventory Helper
Project version : 0.1
PURPOSE
Database connection
*/
$servername = "localhost:3308";
$username = "homeinventorydev";
$password = "xFog2f8NIrP6MGpl"; //here
$dbname = "homeinventorydevdb";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
//display a user friendly message
//if code:2002, message = the connection to the database could not be done. Check the connection parameters, check if the database has been created.
if($e->getCode() == 2002){
echo $sql ."<br> Code: " . $e->getCode() . "<br>The connection to the database could not be done. Check the connection parameters, check if the database has been created." . $e->getMessage();
}
}// exception handling ends here
?>