Ayuda tengo un error de la funcion bind_param

Estoy teniendo este error “Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp2\htdocs\Sertec\Sertec\Formulario\conexion.php:93 Stack trace: #0 {main} thrown in C:\xampp2\htdocs\Sertec\Sertec\Formulario\conexion.php on line 93”

<?php
if (isset($_POST['Sucursal'])) {
    $Sucursal = $_POST['Sucursal'];
}
if (isset($_POST['Nombre'])) {
    $Cliente = $_POST['Nombre'];
}
if (isset($_POST['cedula'])) {
    $RUT = $_POST['cedula'];
}
if (isset($_POST['Fono'])) {
    $Fono = $_POST['Fono'];
}
if (isset($_POST['Direccion'])) {
    $Direccion = $_POST['Direccion'];
}
if (isset($_POST['Comuna'])) {
    $Comuna = $_POST['Comuna'];
}
if (isset($_POST['Region'])) {
    $Region = $_POST['Region'];
}
if (isset($_POST['FechaCompra'])) {
    $FechaCompra = $_POST['FechaCompra'];
}
if (isset($_POST['Articulo'])) {
    $Articulo = $_POST['Articulo'];
}
if (isset($_POST['Marca'])) {
    $Marca = $_POST['Marca'];
}
if (isset($_POST['Modelo'])) {
    $Modelo = $_POST['Modelo'];
}
if (isset($_POST['NSerie'])) {
    $NSerie = $_POST['NSerie'];
}
if (isset($_POST['Accesorio'])) {
    $Accesorio = $_POST['Accesorio'];
}
if (isset($_POST['Garantia'])) {
    $Garantia = $_POST['Garantia'];
}
if (isset($_POST['MotivoIngreso'])) {
    $MotivoIngreso = $_POST['MotivoIngreso'];
}
if (isset($_POST['InformeReparacion'])) {
    $InformeReparacion = $_POST['InformeReparacion'];
}
if (isset($_POST['RepuestosUsados'])) {
    $RepuestosUsados = $_POST['RepuestosUsados'];
}
if (isset($_POST['FechaRecepcion'])) {
    $FechaRecepcion = $_POST['FechaRecepcion'];
}
if (isset($_POST['FechaPropuesta'])) {
    $FechaPropuesta = $_POST['FechaPropuesta'];
}
if (isset($_POST['FechaEntrega'])) {
    $FechaEntrega = $_POST['FechaEntrega'];
}
if (isset($_POST['Repuestos'])) {
    $Repuestos = $_POST['Repuestos'];
}
if (isset($_POST['Total'])) {
    $Total = $_POST['Total'];
}

if (!empty($Sucursal) || !empty($Nombre)|| !empty($cedula)|| !empty($Fono)|| !empty($Direccion)|| !empty($Comuna)|| !empty($Region)|| !empty($FechaCompra)|| !empty($Articulo)|| !empty($Marca)|| !empty($Modelo)|| !empty($NSerie)|| !empty($Acessorio)|| !empty($Garantia)|| !empty($MotivoIngreso)|| !empty($InformeReparacion)|| !empty($RepuestosUsados)|| !empty($FechaRecepcion)|| !empty($FechaPropuesta)|| !empty($FechaEntrega)|| !empty($Repuestos)|| !empty($Total) ){
	
	$host="localhost";
	$dbuser="root";
	$dbpass="";
	$dbname="javiera";

	$conn= new mysqli($host,$dbuser,$dbpass,$dbname);
	if (mysqli_connect_error()) {
		die('Connect Error('.mysqli_connect_errorno().')'.mysqli_connect_error());
	}
	else
		$SELECT = "SELECT Fono from formulario_sertec where Fono = ? limit 1";
		$INSERT = "INSERT INTO formulario_sertec (Sucursal, Cliente, cedula, Fono, Direccion, Comuna, Region, FechaCompra, Articulo, Marca, Modelo, NSerie, Acessorio, Garantia, MotivoIngreso, InformeReparacion, RepuestosUsados, FechaRecepcion, FechaPropuesta, FechaEntrega, Repuestos, Total) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

		$stmt = $conn -> prepare($SELECT);
		$stmt ->bind_param("i",$Fono);
		$stmt ->execute();
		$stmt ->bind_result($Fono);
		$stmt ->store_result();
		$rnum= $stmt->num_rows;
		if ($rnum == 0) {
			$stmt ->close();
			$stmt = $conn -> prepare($INSERT);
			$stmt ->bind_param('sssissssssssssssssssss',$Sucursal,$Cliente,$RUT, $Fono, $Direccion, $Comuna, $Region, $FechaCompra, $Articulo, $Marca, $Modelo, $NSerie, $Accesorio, $Garantia, $MotivoIngreso, $InformeReparacion, $RepuestosUsados, $FechaRecepcion, $FechaPropuesta, $FechaEntrega, $Repuestos, $Total);

			$stmt->execute();
			echo "Registro Completado";
		}
		else{
			echo "alguien ya registro ese número";
		}
		$stmt->close();
		$conn->close();

	}


?>


@ignaciaame209

No hablo español, usando Google Translate aquí, lo siento. Solo intento ayudar porque estoy familiarizado con PHP. Espero que entiendas …

¿Cuál es su esquema o estructura para su base de datos? ¿Ha cometido un error tipográfico en su PHP para el nombre de una tabla o columna o algo así?

¿Está intentando vincular en una tabla o columna que no existe? Verifique el esquema / estructura de su base de datos. Verifique su código para ver si hay errores tipográficos.

¿Tiene phpmyadmin instalado y configurado para que pueda verificarlo fácilmente?

¿Está comprobando si su declaración de preparación devuelve falso?

English Translation:

I don’t speak Spanish, using Google Translate here, sorry. I’m just trying to help because I’m familiar with PHP. I hope you understand …

What is your schema or structure for your database? Have you made a typo in your PHP for a table or column name or something?

Are you trying to link on a table or column that doesn’t exist? Check your database schema / structure. Check your code for typographical errors.

Do you have phpmyadmin installed and configured so you can verify it easily?

Are you checking in case your prepare statement returns `` `false```?

@ignaciaame209

Lo siento, de nuevo hablo inglés, de nuevo utilicé el Traductor de Google. Espero que tenga sentido…

En la base de datos javiera, nombre de la tabla formulario_sertec ¿hay una columna llamada Cliente o se llama Nombre ? Compruebe esto.

Además, veo algunas otras cosas menores …

No veo en qué otro lugar de su código declaró o definió
$Nombre , está almacenando $_POST['Nombre'] en la variable $Cliente .

if (isset($_POST['Nombre'])) {
    $Cliente = $_POST['Nombre'];
}

No está comprobando si $Cliente está vacío.

if (!empty($Sucursal) || !empty($Nombre)|| #¿quiso comprobar por $Cliente? 

Traducción en inglés:
English translation:

Sorry, again I am English speaker, again I used Google Translate. I hope it makes sense…

In database javiera, table name formulario_sertec is there a column called Cliente or is it called Nombre? Check for this.

Also, I see a few other minor things…

I do not see where else in your code you declared or defined
$Nombre, you are storing $_POST['Nombre'] in variable $Cliente

You are not checking if $Cliente is empty.

No hablo español, así que estoy usando el traductor de Google. Espero que esto se traduzca lo suficientemente bien como para que lo entiendas. Le respondo para decirle que hay una sección en español en este sitio que puede ser más fácil para usted navegar. aquí está: Español - The freeCodeCamp Forum. espero que esto ayude
Pido disculpas si esto no se traduce bien. solo puedo hablar inglés con fluidez. mis disculpas

english translation:
I don’t speak Spanish so I am using Google Translate. Hope this translates well enough for you to understand. I respond to tell you that there is a Spanish section on this site that may be easier for you to navigate. Here it is: Español - The freeCodeCamp Forum. I hope this helps.
I apologize if this does not translate well. I can only speak English fluently. my apologies

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.