I have this external file CreateConnection.php that has a class DBController and its following functions. The createconnection file encounters no errors.
CreateConnection.php file inside
<?php
class DBController
{
    private $servername = "localhost";
    private $username = "root";
    private $password = "";
    private $database = "mydatabase";
    function mainConnect()
    {
        //call the function connectDatabase to $connect
        $connect = $this->connectDatabase();
       //call the function selectDatabase
        $this->selectDatabase($connect);
        if(!$connect)
        {
            //Otherwise, prompt connection failed
            die("Connection failed: ".mysqli_connect_error());
        }
    }
    function connectDatabase()
    {
        //Create connection
        $connect = mysqli_connect($this->servername, $this->username, $this->password);
        return $connect;
    }
    function selectDatabase($connect)
    {
         //Select database
         mysqli_select_db($connect, $this->database);
    }
}
?>
In this file, I include the external CreateConnection.php , but my '$connect' encounters many errors when calling the mainConnect() function. Process.php file
<?php
    include("CreateConnection.php");
    $DBHandler = new DBController();
    $connect = $DBHandler->mainConnect();
    //Get values from form LoginReminder.php file
    $username = mysqli_real_escape_string($connect, $_POST['username']);
    $password = mysqli_real_escape_string($connect, $_POST['password']);
    //Removes back slashes in input
    $username = stripcslashes($username);
    $password = stripcslashes($password);
    //Query the database for users
    $result = mysqli_query($connect,"select * from tablereminders where username = '$username' and password = '$password' ");
    //Error connection and query
    if (!$result)
    {
        printf("Error: %s\n", mysqli_error($connect));
        exit();
    }
?>
Does my syntax is incorrect since I've encountered this many errors when submitting a form:
Errors
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Web Php Tutorial\LoginProcess.php on line 8
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Web Php Tutorial\LoginProcess.php on line 9
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Web Php Tutorial\LoginProcess.php on line 15
Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Web Php Tutorial\LoginProcess.php on line 20
 
     
    