Click here to Skip to main content
15,611,691 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Fatal error: Uncaught mysqli_sql_exception: Unknown database 'dms_db' in C:\xampp\htdocs\dms\classes\DBConnection.php:18 Stack trace: #0 C:\xampp\htdocs\dms\classes\DBConnection.php(18): mysqli->__construct('localhost', 'root', '', 'dms_db') #1 C:\xampp\htdocs\dms\classes\SystemSettings.php(8): DBConnection->__construct() #2 C:\xampp\htdocs\dms\classes\SystemSettings.php(257): SystemSettings->__construct() #3 C:\xampp\htdocs\dms\config.php(9): require_once('C:\\xampp\\htdocs...') #4 C:\xampp\htdocs\dms\index.php(1): require_once('C:\\xampp\\htdocs...') #5 {main} thrown in C:\xampp\htdocs\dms\classes\DBConnection.php on line 18

What I have tried:

class DBConnection{

    private $host = DB_SERVER;
    private $username = DB_USERNAME;
    private $password = DB_PASSWORD;
    private $database = DB_NAME;
    public $conn;
    public function __construct(){

        if (!isset($this->conn)) {
            $this->conn = new mysqli($this->host, $this->username, $this->password, $this->database);
            if (!$this->conn) {
                echo 'Cannot connect to database server';
    public function __destruct(){
Updated 29-Jan-23 20:30pm

The error message is perfectly clear: the server you're connecting to doesn't have a database called dms_db.

Either you're connecting to the wrong server, or you've specified the wrong database name, or you forgot to create the database.
Share this answer
OriginalGriff 15-Jun-22 9:59am    
You do have to wonder if some people actually read error messages at all, don't you? :sigh:
Richard MacCutchan 15-Jun-22 11:12am    
Why read what you can paste into CodeProject? :/
Fatal error: Uncaught mysqli_sql exception: Unknown database ecommerce in Champp\htdocdonline-shopping-system.php:9 Stack trace o Champpotentne chopping systemidb.php(9): mysqli_connect('localhost' root, Object[SensitiveParameterValue) ecommerce) at Champptdocslonline-shopping systemieader pho include Campinasic 2.Cxampphhtdocsonline-shopping-systemlindex.php(4) Include Campihtdocs/#3 (main) thrown in Campdocslonline-shopping systemdb.phponpage no 9
Share this answer
Richard Deeming 30-Jan-23 4:34am    
Your error message is not a "solution" to someone else's error message.

And if you'd bothered to read the rest of the page, you'd see that you already have the solution right in front of you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900