I've recently encountered an error in my code:
PHP Parse error: syntax error, unexpected '$connection' (T_VARIABLE), expecting function (T_FUNCTION) in
From what I've googled the issue is not setting public/private/protected before, or not creating the database connection in the construct function.
The database connection class code:
class databaseConnection {
//Database information
protected $mysqliUser = "";
protected $mysqliHost = "localhost";
protected $mysqlipass = "";
protected $mysqlidbname = "";
public $con;
public function __construct() {
$this->con = new mysqli($this->mysqliHost,$this->mysqliUser,$this-
>mysqlipass,$this->mysqlidbname);
}
}
A snippet of the class code that is receiving the error:
private $conn;
$conn = new databaseConnection;
Any help to point me in the right direction is much appreciated.
public $this->connectionand yourreturnstatement in your__construct.__constructmethod can't return a value.