Вызов функции-функции-члена () на null

Я новичок в программировании на PHP, и я делаю класс PHP, который получает запросы, но когда вызываемый дает мне ошибку «PHP Fatal error: вызов функции-функции-члена () на null». Можете ли вы помочь мне увидеть, что происходит?

Это код класса PHP

class conectar{ public $conexion; var $svrName; var $user; var $pwd; var $dbName; var $consult; function set_conexion($new_conexion){ $this->conexion=$new_conexion; } function get_conexion(){ return $this->conexion; } function set_server($new_svrName){ $this->svrName=$new_svrName; } function get_server(){ return $this->svrName; } function set_user($new_usere){ $this->user=$new_user; } function get_user(){ return $this->user; } function set_pwd($new_pwd){ $this->pwd=$new_pwd; } function get_pwd(){ return $this->pwd; } function set_dbName($new_dbName){ $this->pwd=$new_dbName; } function get_dbName(){ return $this->dbName; } function conectarDB($svrName, $user, $pwd,$dbName){ $conexion = mysqli_connect($svrName, $user, $pwd,$dbName); return $conexion; } function consultaDB($consult){ $result = $conexion->query($conexion,$consult); return $result; } function disconnectDB($conexion){ $close = mysqli_close($conexion); return $close; } } 

Поэтому я звоню

 <?php include("conectar.php"); $con = new conectar(); $con->conectarDB("localhost","root","root","contactos"); $query = "Select * from pais order by nombre"; $ejeConsulta = $con->consultaDB($query); while ($result = $ejeConsulta->fetch_assoc()){ echo "<option value='".$result["pais"]."'>".$result["pais"]."</`enter code here`option>"; } ?> в <?php include("conectar.php"); $con = new conectar(); $con->conectarDB("localhost","root","root","contactos"); $query = "Select * from pais order by nombre"; $ejeConsulta = $con->consultaDB($query); while ($result = $ejeConsulta->fetch_assoc()){ echo "<option value='".$result["pais"]."'>".$result["pais"]."</`enter code here`option>"; } ?> 

Спасибо за помощь

Неверные области переменных. Попробуй это:

 function conectarDB($svrName, $user, $pwd,$dbName){ $this->conexion = mysqli_connect($svrName, $user, $pwd,$dbName); return $this->conexion; } function consultaDB($consult){ $result = $this->conexion->query($consult); return $result; }