PHP、MySQL 错误 : Column count doesn't match value count at row 1

标签 php mysql

我收到这个错误:

列计数与第 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 个值。尝试添加该方法。

关于PHP、MySQL 错误 : Column count doesn't match value count at row 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35969389/

相关文章:

php - 为什么我的 PHP include 函数不能正常工作?

mysql - Left 函数遗漏字符

java - Jersey 休息服务 + mySQL 数据库 : No suitable driver found

SQL 子查询获取特定列

mysql - 为什么mysql查询返回不同的结果?

PHP如何查询日期时间?

php - 使用 jquery 加载 php 页面

php - 访问 googleapis 失败

php - Wordpress 循环在页面循环开始时创建空白空间

php - 如何在没有安装 SMTP 服务器的情况下从 PHP 发送电子邮件?