Hey guys I am developing a database connection with OOP PHP and I am stuck on this error;
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Users...\function.php on line 26.
I am new to OOP so any help greatly appreciated
<?php
class MyClass{
var $HOST = "localhost";
var $USER = "user";
var $PASS = "pass";
var $DB = "image_blog";
public $con;
function _construct(){
$this->host = $HOST;
$this->user = $USER;
$this->pass = $PASS;
$this->db = $DB;
$this->con = mysqli_connect($this->host, $this->user, $this->pass, $this->db);
}
public function query($sql)
{
$query = mysqli_query($this->con,$sql);
return $query;
}
}
$obj = new Myclass;
echo $obj->query("SELECT * FROM posts");