CarpeCodice
Coder
Hi!
I have the following code in admin/config/dbcon.php which establishes a connection to a database called "costing".
The admin/config/dbcon.php is called as an 'include' in the admin/index.php file:
If the connection fails, what I want to happen is to be redirected to ../errors/dberror.php - but it does not. Instead of redirecting, it simply gives me a fatal error message on the page (tested by changing the database name in the above code to something else): Fatal error: Uncaught mysqli_sql_exception: Unknown database 'costingblahblah'...
Below is the file structure where you can see the 3 files mentioned in this thread:
Any help would be greatly appreciated!
Thank you in advance.
I have the following code in admin/config/dbcon.php which establishes a connection to a database called "costing".
Code:
<?php
$host = "localhost";
$username = "root";
$password = "";
$database = "costing";
$con = mysqli_connect("$host","$username","$password","$database");
if(!$con) {
header("Location: ../errors/dberror.php");
die();
}
?>
The admin/config/dbcon.php is called as an 'include' in the admin/index.php file:
Code:
<?php
include('config/dbcon.php');
?>
If the connection fails, what I want to happen is to be redirected to ../errors/dberror.php - but it does not. Instead of redirecting, it simply gives me a fatal error message on the page (tested by changing the database name in the above code to something else): Fatal error: Uncaught mysqli_sql_exception: Unknown database 'costingblahblah'...
Below is the file structure where you can see the 3 files mentioned in this thread:
Any help would be greatly appreciated!
Thank you in advance.