Error of passage by reference, insert in the bank

-3

I had the following errors:

  

Notice: Only variables should be passed by reference in   /var/www/html/crud/banco/Banco.php on line 30

     

Notice: Only variables should be passed by reference in   /var/www/html/crud/banco/Banco.php on line 31

     

Notice: Only variables should be passed by reference in   /var/www/html/crud/banco/Banco.php on line 32

     

Notice: Only variables should be passed by reference in   /var/www/html/crud/banco/Banco.php on line 33

And I have the following code, can someone give me a light, can not do it like this?

public function insert($table, Post $post){       
    if(empty($table) == false){
        $this->stm = $this->pdo->prepare("insert into ".$table." (titulo, data_criado, corpo, autor) values(?, ?, ?, ?)");
        $this->stm->bindParam(1, $post->getTitulo());
        $this->stm->bindParam(2, $post->getData_criacao());
        $this->stm->bindParam(3, $post->getCorpo());
        $this->stm->bindParam(4, $post->getAutor());

        $this->stm->execute();
    }
}
    
asked by anonymous 24.03.2018 / 02:22

1 answer

0

Switch $post->getTitulo() by a variable.

Example: $titulo = $post->getTitulo();

You can not change the value of what is being passed in bindParam, which is what $ post-> getTitulo () is doing.

    
27.04.2018 / 04:10