Uncaught Error: Call to a Member Function prepare() on null in

Asked

Viewed 908 times

0

I am trying to register my customer address and he gives the following message:

Uncaught Error: Call to a member function prepare() on null in 

I have no idea what it might be, I query it this way:

$this->Conexao->prepare($sql)->execute()

According to this error it seems to me that it is considering my variable $sql as null, but I asked to write it on the screen and it is normal. Even because I before happening the registration that is giving this error php makes another before.

  • 2

    hi, your connection is not valid, view user, password ip, bank. See in the code if you are not doing some assignment on a local variable instead of the property Conexao

  • 1

    It seems that the problem is in$this->Connected, put your whole class for us to see

1 answer

1


I found the problem

Why this error appeared was the following. I created a class to be responsible for the contact and the address:

class Endereco extends AbsGeral
{
    function __construct()
    {

    }
}

The mistake was that I instituted this class so:

$end = new Endereco;

Being that there was a Construct asking parameter. I simply removed this Construct that should not even exist and it worked perfectly. Here’s the tip in case someone goes through the same thing I did.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.