I have the following functions:
function query($stmt){
try{
return mysqli_stmt_execute($stmt);
}
finally{
mysqli_stmt_close($stmt);
mysqli_close($GLOBALS['conexao']);
}
}
function cadastrarNoBanco($nome, $email){
$ip = getIp();
$stmt = mysqli_prepare($GLOBALS['conexao'], "INSERT INTO tbl_lead VALUES(default, ?, ?, ?, default)");
return query(mysqli_stmt_bind_param($stmt, 'sss', $nome, $email, $ip));
}
But you are giving the following error when calling cadastrarNoBanco()
:
Warning: mysqli_stmt_execute () expects parameter 1 to be mysqli_stmt, boolean given
I've tried to pass stmt
by reference, but it does not work. I thought it was an error in the query syntax, but if I run it directly in MySql, it looks good.