Fatal error: Call to a member function query () on null

1

I am programming the Log In of a page in PHP within WordPress and I get this error:

  

Fatal error: Call to a member function query () on null in /home3/georgerojas/public_html/contablesjm.com/wordpress/conexiondb.php on line 35

I know something about PHP but they tell me that in this case I should use PHP7.

Can anyone help me?

<?php

//conexionDb
class conexion
{
    private $conexion;
    private $host = "localhost";
    private $user = "georgero_conjmbd";
    private $pw   = "contablesjm17";
    private $bd   = "georgero_jmcontables";
    /*private $user;*/
    private $password;

    public function __constuct()
    {
        $this->conexion = new mysqli($this->host, $this->user, $this->pw, $this->bd);

        if ($this->conexion->connect_errno) {
            die("fallo al tratar de conectar con MYSQL: (" . $this->conexion->connect_errno . ")");
        }
    }

    public function cerrar()
    {
        $this->conexion->close();
    }

    public function login($usuario, $contrasena)
    {
        $this->usuario  = $usuario;
        $this->password = $contrasena;

        $query = "select nombre, apellido from usuario where nombre='" . $this->usuario . "' or correo='" . $this->usuario . "' and contrasena='" . $this->password . "'";

        $consulta = $this->conexion->query($query);

        if ($row = mysqli_fetch_array($consulta)) {

            session_start();

            $_session['nombre']   = $row['nombre'];
            $_session['apellido'] = $row['apellido'];

            echo "has iniciado Sesion";

        } else {
            echo "usuario o contraseña incorrectos";
        }
    }
}
?>
    
asked by Alfonso 01.03.2017 в 18:54
source

0 answers