-3
I’ve had the following mistakes:
Notice: Only variables should be passed by Ference in /var/www/html/crud/bank/Banco.php on line 30
Notice: Only variables should be passed by Ference in /var/www/html/crud/bank/Banco.php on line 31
Notice: Only variables should be passed by Ference in /var/www/html/crud/bank/Banco.php on line 32
Notice: Only variables should be passed by Ference in /var/www/html/crud/bank/Banco.php on line 33
And I have the following code below, someone can give me a light, it’s not possible to do it this way ?
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();
}
}
At the very least
insert
is misspelled in query. It is written asinert
– Isac
already fixed this and continues the same error, I am java programmer I am migrating to PHP, is that in java I could pass an object to the method that would use the Insert, but here PHP am not getting
– Mestre Splinter
presents some error
– Marcelo Batista
yes esses ai 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/bank/Banco.php on line 32 Notice: Only variables should be passed by Reference in /var/www/html/crud/bank/Banco.php on line 33
– Mestre Splinter
Behold
bindParam
andbindValue
. ThebindParam
expects a reference, such as the notice indicates.– Isac
puts the rest of the code
– Marcelo Batista
just switched from bindParam to bindValue was that really thank you, guys worth the community is helping me a lot in this my entry in PHP, Thank you aeee
– Mestre Splinter
Possible duplicate of Error when using bindParam: Only variables should be passed by Reference
– Sveen