0
I have the following duties:
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’re making the following mistake by calling cadastrarNoBanco()
:
Warning: mysqli_stmt_execute() expects Parameter 1 to be mysqli_stmt, Boolean Given
I tried to pass the stmt
by reference, but it doesn’t work. I thought it was an error in the query syntax, but if I run it directly in Mysql, it is good.
Do not pass
mysqli_stmt_bind_param
as parameter. It returns a boolean, not stmt. In fact this function receives stmt by reference and modifies it, so call this function separately and pass the direct stmt as parameter ofquery
.– Woss
@Andersoncarloswoss It worked! Want to make an answer to that?
– Francisco