Coding Class

Quizgum : Project 1-3 : Create Database Connection Page

Creating a Database Connection Page

Hello, this time let's create a page to access the database.
Database connection information is based on the basic information of MAMP.
Set the default connection information for your apm package program.
Basic connection information means user, password.
create folder myProject in htdocs

php image

and then create folder include in myProject

php image

^^ The source is as below.


    $host = 'localhost';
    $user = 'root';
    $passWord = 'root'; //your password
    $dbName = 'myproject';

    $dbConnect = new mysqli($host, $user, $passWord, $dbName);

        echo "DB Connection Failed." . mysqli_connect_error();


php image


php image

If you put host, user, password, and db's name in mysqli class, it will be connected to the db ^^.
So let's move on to the next class.