错误 将数据插入数据库时,列计数与第 1 行的值计数不匹配


error Column count doesn't match value count at row 1 while inserting data to my db

我有一个我正在做的电子商务网站。现在,每次尝试将数据插入数据库时,我都会收到该错误。我正在尝试插入有关表买家和消息的详细信息,但我不知道错误在哪里。

我不知道错误在哪里,请帮助我:

我的代码:

$buyer_name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$mobile_no = $_POST['mobile_no'];
$id_no = $_POST['id_no'];
$total = $_POST['total'];
echo '<a href="index.php">Home</a><br>';
echo 'Thank you for shopping at our Thread online store. And the following is the data you enter.';
echo '<p>The total cost for the purchase of products is:Tsh '.$total.
'/=, and the cost can be send through the M-Pesa mobile number +255 757 393 937, Airtel Money: # and Tigo-Pesa: #.</p>';
echo '<p>And the goods will be sent to the address below:</p>';
echo '<p>Name : '.$buyer_name.
'<br>';
echo '<p>Address and Location : '.$address.
'</p>';
echo '<p>Total Price : '.$total.
'</p>';
echo '<p>With Details : </p>';
$p = mysql_query("SELECT * FROM buyer");
$cek = mysql_fetch_array($p);
$c1 = $cek['name'];
$c2 = $cek['address'];
$c3 = $cek['email'];
$c4 = $cek['mobile_no'];
$c5 = $cek['id_no'];
if ($c1 == $buyer_name && $c2 == $address && $c3 == $email && $c4 == $mobile_no && $c5 == $id_no) {
    $i = 1;
    foreach($_SESSION as $name => $value) {
        if ($value > 0) {
            if (substr($name, 0, 5) == 'cart_') {
                $id = substr($name, 5, (strlen($name) - 5));
                $get = mysql_query("SELECT * FROM products WHERE product_id='$id'");
                while ($get_row = mysql_fetch_assoc($get)) {
                    $sub = $get_row['product_price'] * $value;
                    echo ' < table class = "table table-striped" >
                        < thead >
                        < tr >
                        < th > # < /th> < th > Product ID < /th> < th > Product Name < /th> < th > Quantity < /th> < /tr> < /thead> < tbody >
                        < tr >
                        < td > '.$i.' < /td> < td > '.$get_row['
                    product_id '].' < /td> < td > '.$get_row['
                    product_title '].' < /td> < td > '.$value.' < /td> < /tr> < /tbody < /table>';
                        //<p>'.$i.' '.$get_row['product_id'].' '.$get_row['product_title'].' '.$value.' SubTotal : Tsh '.$sub.' /=</p>                                      
                    $getBuyer = mysql_query("SELECT buyer.id, buyer.name, buyer.address, products.product_id, products.product_title FROM buyer, products WHERE name='$buyer_name' AND address='$address'") or die(mysql_error());
                    $data = mysql_fetch_array($getBuyer);
                    $pemb = $data['id'];
                    $na = $data['name'];
                    $al = $data['address'];
                    $ib = $get_row['product_id'];
                    $nb = $get_row['product_title'];
                    //echo $total;
                    $i++;
                }
            }
            //@$total += $sub;
            mysql_query("INSERT INTO message VALUES('', '$pemb', '$na', '$al', '$ib', '$nb', '$value', '$sub', now()) ") or die(mysql_error());
        }
    }
} else {
    //Insert Data of the buyer to the db
    $query = mysql_query("INSERT INTO buyer VALUES( '$buyer_name', '$email', '$address', '$mobile_no', '$id_no')") or die(mysql_error());
    $i = 1;
    foreach($_SESSION as $name => $value) {
        if ($value > 0) {
            if (substr($name, 0, 5) == 'cart_') {
                $id = substr($name, 5, (strlen($name) - 5));
                $get = mysql_query("SELECT * FROM products WHERE product_id='$id'");
                while ($get_row = mysql_fetch_assoc($get)) {
                    $sub = $get_row['product_price'] * $value;
                    echo ' < table class = "table table-striped" >
                        < thead >
                        < tr >
                        < th > # < /th> < th > Product ID < /th> < th > Product Name < /th> < th > Quantity < /th> < /tr> < /thead> < tbody >
                        < tr >
                        < td > '.$i.' < /td> < td > '.$get_row['
                    product_id '].' < /td> < td > '.$get_row['
                    product_title '].' < /td> < td > '.$value.' < /td> < /tr> < /tbody < /table>';  
                    $getBuyer = mysql_query(" SELECT buyer.id, buyer.name, buyer.address, products.product_id, products.product_title FROM buyer, products WHERE name='$buyer_name' AND address='$address'") or die(mysql_error());
                    $data = mysql_fetch_array($getBuyer);
                    $pemb = $data['id'];
                    $na = $data['name'];
                    $al = $data['address'];
                    $ib = $get_row['product_id'];
                    $nb = $get_row['product_title'];
                    //echo $total;
                    $i++;
                }
            }
            //@$total += $sub;
            mysql_query("INSERT INTO message VALUES('', '$pemb', '$na', '$al', '$ib', '$nb', '$value', '$sub', now()) ") or die(mysql_error());
        }
    }
}

/*if ($query) 
                              {
                                  header('location:index.php');
                              }*/
session_destroy();

必须定义要插入的字段名称

相反

$query = mysql_query("INSERT INTO buyer VALUES( '$buyer_name', '$email', '$address', '$mobile_no', '$id_no')") or die(mysql_error());  

像这样用于插入buyer

$query = mysql_query("INSERT INTO buyer(name,email,address,mobile,id) VALUES( '$buyer_name', '$email', '$address', '$mobile_no', '$id_no')") or die(mysql_error());