Mysql database insertion problem in php

Asked

Viewed 39 times

1

I am developing a project for the college and I am having some problems to perform the insertion in the my_sql database, my problem is in this excerpt.

mysqli_query($conn, "INSERT INTO funcionario(
      codigo_funcionario,
      nome,
      cpf,
      data_nascimento,
      telefone,
      estado,
      motivo,
      periodo,
      cidade,
      rua,
      bairro,
      numero,
      complemento,
      cep,
      cnpj_empresa
    ) VALUES (
      '".$this->getCodigoDoFuncionario()."',
      '".$this->getNome()."',
      '".$this->getCPF()."',
      '".$this->getDataNascimento()."',
      '".$this->getTelefone()."',
      '".$this->getEstado()."',
      '".$this->getMotivo()."',
      '".$this->getPeriodo()."',
      '".$this->endereco->getCidade()."',
      '".$this->endereco->getRua()."',
      '".$this->endereco->getBairro()."',
      '".$this->endereco->getNumero()."',
      '".$this->endereco->getComplemento()."',
      '".$this->endereco->getCEP()."',
      ''
    );");

My problem lies in the moment I do

'".$this->endereco->getCidade()."'

I don’t know if the problem is with my class, or if the syntax is wrong.

I am having these two errors "Undefined Property" and "Fatal error: Call to a Member Function getCidade() on null". Could you give me a hand? Thanks!

  • Friend, by the error you have "Fatal error: Call to a Member Function getCidade() on null", you probably forgot to instantiate the address object.

  • 1

    A yes, really, my __Construct was written construc instead of UAHAUHUAH Construct, thanks man!!

  • leandro, writes the answer to the question so that Ricardo can select as chosen and the post stay as answered.

  • Read about injection of SQL, this is a very serious problem that there is in your code.

No answers

Browser other questions tagged

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