0

Making a demo menu, and I keep getting :

Array ( [0] => 21S01 [1] => 1136 [2] => Column count doesn't match value count at row 1

I have tried recreating my tables, I still cannot seem to find the problem. Everything works until I start adding my menu items with the code below :

if (!empty($_POST['wings'])) {
    $wings=$_POST['wings'];
    $sql =$DBH->prepare("INSERT INTO orders VALUES ('', :payment_id, 'Boneless Wings and Skins Sampler', :wings)");
    $sql->execute( array(':payment_id'=>$payment_id, ':wings'=>$wings) )or die(print_r($sql->errorInfo(), true));
}
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • You have already been told the error, the amount of 'values' you're trying to insert doesn't equal the amount of columns in the table. Without seeing your schema, it's going to be difficult for anybody to help further. – Jack hardcastle Apr 29 '19 at 14:37
  • your orders table contains more columns than those you are trying to insert. if you explicitly mention those column you are trying to insert then you will be ok – Lelio Faieta Apr 29 '19 at 15:03

1 Answers1

-1

The problem is as the error states: You are trying to insert a different number of values than there are columns in the table, without explicitly stating the column names.

In this case you need to either state the column names you are inserting to, or make sure exactly the same number of values are being inserted as the number of columns in the table you are inserting into.