列计数不为';第1行的值计数不匹配-PHP,MySql

列计数不为';第1行的值计数不匹配-PHP,MySql,php,mysql,Php,Mysql,我通过PHP在MySql数据库中插入了一些数据,但不幸的是,我遇到了以下错误: 错误:列计数与第1行的值计数不匹配 从以下代码: <?php if($_POST) { include_once('dbconn.php'); $profile_created_by = $_POST['profile_created_by']; $name = $_POST['name']; $gender = $_POST['gender']; $dd = $_POST['dd']; $mm = $_POS

我通过PHP在MySql数据库中插入了一些数据,但不幸的是,我遇到了以下错误:

错误:列计数与第1行的值计数不匹配

从以下代码:

<?php
if($_POST)
{
include_once('dbconn.php');
$profile_created_by = $_POST['profile_created_by'];
$name = $_POST['name'];
$gender = $_POST['gender'];
$dd = $_POST['dd'];
$mm = $_POST['mm'];
$yyyy = $_POST['yyyy'];
$dob = $dd.'-'.$mm.'-'.$yyyy;
$marital_status = $_POST['marital_status'];
$religion = $_POST['religion'];
$mother_tongue = $_POST['mother_tongue'];
$country = $_POST['country'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$password = $_POST['password'];
$sql="INSERT INTO user VALUES ('$profile_created_by', '$name', '$gender', '$dob', '$marital_status', '$religion', '$mother_tongue', '$country', '$mobile', '$email', '$password')";
if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
echo "Entered data successfully";
mysql_close($conn);
}
?>

您收到此错误,因为表
用户中的列数与提供的值数不匹配。因此,请尝试使用这种格式:

INSERT INTO user(columnNames,...) 
VALUES(respective_values,....);

如果用户表中有更多在此未提及的列(例如ID),则必须指定哪个列的数据

$sql="INSERT INTO user (profile_created_by,name,gender,dob,marital_status,religion,mother_tongue,country,mobile,email,password) VALUES ('$profile_created_by', '$name', '$gender', '$dob', '$marital_status', '$religion', '$mother_tongue', '$country', '$mobile', '$email', '$password')";

匹配您的数据库列和插入的值Count(“$profile_created_by”、“$name”、“$gender”、“$dob”、“$monthly_status”、“$religation”、“$母语”、“$country”、“$mobile”、“$email”、“$password”)以及表中的列数