update: error mailing when cannot connect to DB
This commit is contained in:
1 parent
9f76387eec
commit
05086a12f5
1 file changed
+9
-1
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__ . '/../modules/Mail.php';
|
||||
include_once 'DataController.php';
|
||||
|
||||
function db_connect() {
|
||||
$servers = [
|
||||
'local' => [
|
||||
@@ -34,7 +37,7 @@ function db_connect() {
|
||||
],
|
||||
];
|
||||
|
||||
$enviroment = 'live';
|
||||
$enviroment = 'vpn';
|
||||
|
||||
$conn = new mysqli(
|
||||
$servers[$enviroment]['hostaddr'],
|
||||
@@ -45,6 +48,11 @@ function db_connect() {
|
||||
|
||||
if ($conn->connect_error) {
|
||||
throw new Exception('Connection Error: ' . $conn->connect_error);
|
||||
sendMail(
|
||||
"Database connection failed",
|
||||
"Error: $conn->connection_error",
|
||||
(new getSpecificData())->getRequestURL(),
|
||||
);
|
||||
}
|
||||
|
||||
$conn->set_charset("utf8mb4");
|
||||
|
||||
Reference in new issue
Block a user