4
Good morning everyone, I’m starting in PHP, I follow a course through youtube. I’m studying prepared queries. I have a form that makes a query in the BD, however, when entering the data, the following error message appears:
Warning: mysqli_stmt_bind_param() expects Parameter 1 to be mysqli_stmt, Boolean Given in
Below the code:
<?php
$c_art = $_GET["c_art"];
$secc = $_GET["secc"];
$n_art = $_GET["n_art"];
$pre = $_GET["pre"];
$fec = $_GET["fec"];
$imp = $_GET["imp"];
$p_orig = $_GET["p_ori"];
include ("dados_banco.php");
$conexion=mysqli_connect($db_host, $db_usuario, $db_contra);
if (mysqli_connect_errno()) {
echo "Fallo al conectar con la BBDD";
exit();
}
mysqli_select_db($conexion,$db_nombre) or die("No se encunetra la BBDD");
mysqli_set_charset($conexion, "utf-8");
$sql="INSERT INTO productos (CODIGOARTÍCULO, SECCION, NOMBREARTICULO, PRECIO, FECHA, IMPORTADO, PAISDEORIGEN) VALUES (?,?,?,?,?,?,?)";
$resultado=mysqli_prepare($conexion, $sql);
$ok=mysqli_stmt_bind_param($resultado, "sssssss", $c_art, $secc, $n_art, $pre, $fec, $imp, $p_ori);
$ok=mysqli_stmt_execute($resultado);
if($ok==false){
echo "Error al ejecutar la consulta";
}else{
//$ok=mysqli_stmt_bind_result($resultado, $codigo, $seccion, $precio, $pais);
echo "Agregado nuevo registro";
/*while(mysqli_stmt_fetch($resultado)){
echo $codigo . " " . $seccion . " " . $precio . " " . $pais . "<br>";
}*/
mysqli_stmt_close($resultado);
}
?>
$resultado
is false soon fails the query.– rray
Do
$resultado=mysqli_prepare($conexion, $sql) or die(mysqli_error($conexion));
and put the error message.– rray
Laerte, I did the test q asked and noticed that the problem was in some columns of the bank.. mt thank you, it worked! hugs.
– Yan
I believe that in the spine with acute accent in the name, correct?
– Jhonatan Pereira
No, Jhonatan.. the course I am following is in Spanish (I also found it odd that he use accents), and following as it is presented.. was in other field the problem.. obgd by the help
– Yan