So i was following a tutorial on how i can create a website with a database using php and wamp
and am failing on connecting my website to my database
this is the code i wrote
<?php
require ("Entities/CoffeeEntity.php");
class CoffeeModel {
    function GetCoffeeTypes() {
        require 'Credentials.php';
 $mysqli = new mysqli("$servername", "$username", "$password", "$dbname");
        $result = $mysqli->query("Select a distinct Cofffee");
        $types = array();
        while ($row = $result->fetch_assoc()) {
            array_push($types, $row[0]);
        }
        mysql_close();
        return $types;
    }
    function GetCoffeeByType($type) {
        require 'Credentials.php';
        $mysqli = new mysqli("$servername", "$username", "$password", "$dbname");
        $query = "SELECT * FROM coffee WHERE type LIKE '$type'";
        $result = $mysqli->query("error");
        $coffeeArray = array();
        while ($row = $result->fetch_assoc()) {
            $name = $row[1];
            $type = $row[2];
            $price = $row[3];
            $roast = $row[4];
            $country = $row[5];
            $image = $row[6];
            $review = $row[7];
            $coffee = new CoffeeEntity(-1, $name, $type, $price, $roast, $country, $image, $review);
            array_push($coffeeArray, $coffee);
        }
      
        mysql_close();
        return $coffeeArray;
    }
}
?>and this is the error that i get

Edit: ok so i figured out that i need to replace mysql to mysqli
and i tried but it still seems not working cause i guess am doing something wrong
this is the result i came through
<?php
require ("Entities/CoffeeEntity.php");
//Contains database related code for the Coffee page.
class CoffeeModel {
    //Get all coffee types from the database and return them in an array.
    function GetCoffeeTypes() {
        require 'Credentials.php';
        //Open connection and Select database.   
  $mysqli = new mysqli("$servername", "$username", "$password", "$dbname");
        $result = $mysqli->query("Select a distinct Cofffee");
        $types = array();
        //Get data from database.
        while ($row = $result->fetch_assoc()) {
            array_push($types, $row[0]);
        }
        //Close connection and return result.
        mysql_close();
        return $types;
    }
    //Get coffeeEntity objects from the database and return them in an array.
    function GetCoffeeByType($type) {
        require 'Credentials.php';
        //Open connection and Select database.     
        $mysqli = new mysqli("$servername", "$username", "$password", "$dbname");
        $query = "SELECT * FROM coffee WHERE type LIKE '$type'";
        $result = $mysqli->query("error");
        $coffeeArray = array();
        //Get data from database.
        while ($row = $result->fetch_assoc()) {
            $name = $row[1];
            $type = $row[2];
            $price = $row[3];
            $roast = $row[4];
            $country = $row[5];
            $image = $row[6];
            $review = $row[7];
            //Create coffee objects and store them in an array.
            $coffee = new CoffeeEntity(-1, $name, $type, $price, $roast, $country, $image, $review);
            array_push($coffeeArray, $coffee);
        }
        //Close connection and return result
        mysql_close();
        return $coffeeArray;
    }
}
?>and this error shows up
can someone please help and make it work (sorry am really bad at this )

 
     
    