/
Config.php
36 lines (29 loc) · 1.04 KB
/
Config.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
34
35
36
<?php
class Config
{
// Settings \\
private $db_connection = null;
public $logged_in = false;
public $errors = '';
// System Function \\
public function connectDB()
{
try {
$db_host = '192.168.3.46'; // hostname
$db_name = 'matheno_mygig'; // databasename
$db_user = 'matheno_marijke'; // username
$user_pw = 'gabruko3'; // password
$con = new PDO('mysql:host='.$db_host.'; dbname='.$db_name, $db_user, $user_pw);
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$con->exec("SET CHARACTER SET utf8"); // return all sql requests as UTF-8
return $con;
}
catch (PDOException $err) {
echo "harmless error message if the connection fails";
$err->getMessage() . "<br/>";
file_put_contents('PDOErrors.txt',$err, FILE_APPEND); // write some details to an error-log outside public_html
die(); // terminate connection
}
}
}
?>