Call to a member function consultprestamos () on a non-object

0

This is the class and within it I have the function ConsultarPrestamos :

class bibliotecaCliente{

public $PUBLICMYSQL;
function bibliotecaCliente(){
    $this->PUBLICMYSQL = new CONMYSQL;
    $this->PUBLICMYSQL->conectar();

}
    
asked by ALEX 17.03.2017 в 19:15
source

2 answers

0

First of all, you are wrongly initializing your class:

$prestamos = new bibliotecaCliente();
// Te faltó añadir los dos parentesis

Then, the variable $bibliotecaCliente is not inizialized anywhere, so you must access the consultarprestamos(); method by $prestamos which is the instance created previously

$prestamos->consultarprestamos(); 
    
answered by 17.03.2017 в 19:29
-1

Try this way to call the method:

$prestamos->consultarprestamos();
    
answered by 17.03.2017 в 19:23