What is the correct way to use sprintf
in mysqli and make the return IF?
$rs = $mysqli->query(sprintf("INSERT INTO perguntas (chave, nome, email, idade, estado_civil, profissao, religiao, assunto, pergunta, 'data') VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
mysqli_real_escape_string($chave),
mysqli_real_escape_string($_POST['nome']),
mysqli_real_escape_string($_POST['email']),
mysqli_real_escape_string($_POST['idade']),
mysqli_real_escape_string($_POST['estado_civil']),
mysqli_real_escape_string($_POST['profissao']),
mysqli_real_escape_string($_POST['religiao']),
mysqli_real_escape_string($_POST['assunto']),
mysqli_real_escape_string($_POST['pergunta']),
mysqli_real_escape_string($data)));
if (mysqli_query($rs)) {
echo "<script>window.location = '".$baseURL."/enviar-aconselhamento&chave=$chave'</script>";
}else{
die('Error: ' . mysqli_error($mysqli));
}
That way I'm doing above this by returning error:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',)' at line 1