Error: Column count does not match value count at row 1

1

Hi, I'm new to php. And I get this error. What happens is that I'm making an order form. But when I fill out the form, instead of adding the data to the order table I get this error:

Column count does not match value count at row 1

This is the code of my form:

<!doctype html>

 Order       

<form action ="Pedido.php" method ="post" class= "form-register">

    <h2 class = "form__titulo"> Pedido</h2>
    <div class = "contenedor-inputs">

        <input type ="number" name ="numero" placeholder ="Numero" class = "input-48"  required> 
        <input type ="date" name ="fechacreacion" placeholder ="Fecha creacion" class = "input-48" required> 

        <input type ="date" name ="fechavencimiento" placeholder ="Fecha vencimiento" class = "input-48" required> 
        <input type ="text" name ="condiciones" placeholder ="Condiciones" class = "input-48" required> 

        <input type ="number" name ="subtotal" placeholder ="Subtotal" class = "input-48" required> 

        <input type ="number" name ="iva" placeholder ="IVA" class = "input-48" required> 
        <input type ="number" name ="total" placeholder ="Total" class = "input-100" required > 

        <input type ="text" name ="observaciones" placeholder ="Observaciones" class = "input-100" required >    


        <input type ="submit" value ="enviar pedido" class = "btn-enviar">

    <p> </p>
    </div>
</form>
</body>

And this is my php code:

    <?php

include 'conexion.php';



$numero = $_POST["numero"];

$fechac = $_POST["fechacreacion"];

$fechav = $_POST["fechavencimiento"];

$con = $_POST["condiciones"];

$sub = $_POST["subtotal"];

$iva = $_POST["iva"];

$total = $_POST["total"];

$observaciones = $_POST["observaciones"];



$insertar ="INSERT INTO pedido(numero,fechaCreacion,fechaVencimiento,condiciones,subtotal,iva,total,observaciones,Usuario_idUsuario,Proveedor_numeroIdent)VALUES ('$numero','$fechac','$fechav','$con','$sub','$iva','$total','$observaciones')";

$resultado = mysqli_query($conexion,$insertar);

if(!$resultado){
 echo mysqli_error($conexion);

}
else
{
echo 'Se ha llenado el formulario con exito';

}

mysqli_close($conexion);

?>

This is my database

I hope you can help me

    
asked by Ghosting 25.05.2017 в 03:21
source

1 answer

0

The error is that you are saying in INSERT more columns than you send in VALUES

$insertar ="INSERT INTO pedido(numero,fechaCreacion,fechaVencimiento,condiciones,subtotal,iva,total,observaciones,Usuario_idUsuario,Proveedor_numeroIdent)VALUES ('$numero','$fechac','$fechav','$con','$sub','$iva','$total','$observaciones')";

You send 8 values when you wait 10

You are missing the fields Usuario_idUsuario and Proveedor_numeroIden

    
answered by 25.05.2017 / 03:23
source