PHP,MySQL错误:列计数不';不匹配第1行的值计数

PHP,MySQL错误:列计数不';不匹配第1行的值计数,php,mysql,Php,Mysql,我得到了这个错误: 列计数与第1行的值计数不匹配 从以下代码: $name = $_GET['name']; $description = $_GET['description']; $shortDescription = $_GET['shortDescription']; $ingredients = $_GET['ingredients']; $method = $_GET['method']; //$image = $_GET['image']; $username = $_GET['u

我得到了这个错误:

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

从以下代码:

$name = $_GET['name'];
$description = $_GET['description'];
$shortDescription = $_GET['shortDescription'];
$ingredients = $_GET['ingredients'];
$method = $_GET['method'];
//$image = $_GET['image'];
$username = $_GET['username'];
$length = $_GET['length'];
$dateAdded = uk_date();
$conn = mysql_connect('localhost', 'dbname', 'pass');
mysql_select_db('dbname');
$query = sprintf("INSERT INTO dbname (id, Name, Description, shortDescription, Ingredients, Method, Length, dateAdded, Username) VALUES ('', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
    mysql_real_escape_string($name),
    mysql_real_escape_string($description),
    mysql_real_escape_string($shortDescription),
    mysql_real_escape_string($ingredients),
    //mysql_real_escape_string($image),
    mysql_real_escape_string($length),
    mysql_real_escape_string($dateAdded),
    mysql_real_escape_string($username));

    $result = mysql_query($query) or die(mysql_error());

错误是什么意思?

列出了9个字段,但只有8个值。尝试添加该方法。

列出了9个字段,但只有8个值。尝试添加该方法。

插入查询中的列参数数为9,但您只提供了8个值

INSERT INTO dbname (id, Name, Description, shortDescription, Ingredients, Method, Length, dateAdded, Username) VALUES ('', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
查询应该省略“id”参数,因为它是自动生成的(或者无论如何都应该是):


insert查询中的列参数数为9,但您只提供了8个值

INSERT INTO dbname (id, Name, Description, shortDescription, Ingredients, Method, Length, dateAdded, Username) VALUES ('', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
查询应该省略“id”参数,因为它是自动生成的(或者无论如何都应该是):


您的查询有8个甚至可能9个变量,即名称、描述等。但是这些值-->
''%s','%s','%s','%s','%s','%s','%s')”
,总共只有7个,变量的数量必须与值相同


我也遇到了同样的问题,但我已经解决了。希望它也能对您起作用。

您的查询有8个甚至9个变量,即名称、描述等。但是这些值-->
,“%s”,“s”,“s”,“s”,“s”,“s”,“s”,“s”-”
,总共只有7个,变量的数量必须与值相同


我也有同样的问题,但我解决了。希望它也能对你有用。

你有注释出来的
//mysql\u real\u escape\u string($image),
你的查询等待9个变量,你传递它8我将以另一种方式上传图像。图像键位于表中,但未为其插入值。这可能是一个原因吗?你有注释掉
//mysql\u real\u escape\u string($image),
你的查询等待9个变量,你传递它8我将以另一种方式上传图像。图像键位于表中,但未为其插入值。这可能是原因吗?那么你没有解决问题。因为这就是问题所在。然后你没有解决问题。因为这就是问题所在。除了所有字段现在都关闭了1。除了所有字段现在都关闭了1。请注意,这个问题已经得到了回答。没有必要恢复一个1.5年的帖子,除非你可以添加新的内容。无论如何,谢谢你的努力。请注意,这个问题已经得到了回答。没有必要恢复一个1.5年的帖子,除非你可以添加新的内容。无论如何,谢谢你的努力。