1
I am passing input parameters in the database using PDO and O, but when giving the Insert command using the parameters $stm->bindParam(1, $usuario->getnivel());
it returns error saying that I must pass only variables for insertion.
Follows code:
public function cadastrar(Cadastro $usuario) {
$stm = $this->pdo->prepare('INSERT INTO usuarios (nivel,username,senha) VALUES (?,?,?)');
$stm->bindParam(1, $usuario->getnivel());
$stm->bindParam(2, $usuario->getusername());
$stm->bindParam(3, $usuario->getsenha());
$stm->execute();
}
Always put exactly the error that appears, the problem here had nothing to do with orientation to objects or mysql, in case the error is this: Only variables should be passed by Ference, please take it as a constructive tip.
– Guilherme Nascimento
Okay, thank you, I’ll take this detail when possible!
– Lucas Carvalho