PS! After establishing connection to mySQL server and then performing CRUD then it would be a good practice to CLOSE the connection like this:


Connect to MySQL DATABASE using PHP.

    define('HOSTNAME', 'localhost');
    define('USERNAME', 'root');
    define('PASSWORD', '');
    define('DB_NAME', 'crud-app');

    // $conn = mysqli_connect('localhost', 'root', '', 'crud-app');

    $conn = mysqli_connect('HOSTNAME', 'USERNAME', 'PASSWORD', 'DB_NAME');

    if ($conn) {
        echo 'success!!!';
    } else {
        die ("Connection lost!!!" . mysqli_connect_error($conn));
// this CLOSE function is not required with PHP but it would be a good practice.