Q:

Instantiate constructor class with mysqli with php

Im calling a class to connect to my local mySql database via a constructor method. Im getting a 500 error when i start the php file. Is there somthing I'm doing wrong? Im passing the values of the host user pass and dbName into the class when i instantiate it but cannot connect. The db is working fine as I have tested it.
<?php

Class MyDB{

    public $query;
    public $myConnection;

    public function__construct($host, $username, $password, $dbname){

        $this->myConnection = mysqli_connect($host, $username, $password, $dbname);

    }

    public function listScores(){

        $this->query = "SELECT answer FROM correct_guesses" or die("error ..." . mysqli_error($this->$myConnection));

        $result = $this->$myConnection->query($this->query);

        while($row = mysqli_fetch_array($result)) {
        echo $row["answer"] . "<br>";

        }
    }
}

$score = new MyDB('localhost','root','root','scoreDB');

$score->listScores();

?>

A:

Your "public function__construct() has no white space in it. It must be like below:
public function __construct()

It will definitely give you 500 error. 

