<i id='SNvB4'><tr id='SNvB4'><dt id='SNvB4'><q id='SNvB4'><span id='SNvB4'><b id='SNvB4'><form id='SNvB4'><ins id='SNvB4'></ins><ul id='SNvB4'></ul><sub id='SNvB4'></sub></form><legend id='SNvB4'></legend><bdo id='SNvB4'><pre id='SNvB4'><center id='SNvB4'></center></pre></bdo></b><th id='SNvB4'></th></span></q></dt></tr></i><div id='SNvB4'><tfoot id='SNvB4'></tfoot><dl id='SNvB4'><fieldset id='SNvB4'></fieldset></dl></div>

      <bdo id='SNvB4'></bdo><ul id='SNvB4'></ul>

  1. <legend id='SNvB4'><style id='SNvB4'><dir id='SNvB4'><q id='SNvB4'></q></dir></style></legend>

    <tfoot id='SNvB4'></tfoot>
    1. <small id='SNvB4'></small><noframes id='SNvB4'>

    2. PDO 未捕获异常 - 插入值列表与列列表不匹配

      时间:2023-10-05

    3. <legend id='2POxq'><style id='2POxq'><dir id='2POxq'><q id='2POxq'></q></dir></style></legend>
        • <bdo id='2POxq'></bdo><ul id='2POxq'></ul>

          <small id='2POxq'></small><noframes id='2POxq'>

              <i id='2POxq'><tr id='2POxq'><dt id='2POxq'><q id='2POxq'><span id='2POxq'><b id='2POxq'><form id='2POxq'><ins id='2POxq'></ins><ul id='2POxq'></ul><sub id='2POxq'></sub></form><legend id='2POxq'></legend><bdo id='2POxq'><pre id='2POxq'><center id='2POxq'></center></pre></bdo></b><th id='2POxq'></th></span></q></dt></tr></i><div id='2POxq'><tfoot id='2POxq'></tfoot><dl id='2POxq'><fieldset id='2POxq'></fieldset></dl></div>
            • <tfoot id='2POxq'></tfoot>

                <tbody id='2POxq'></tbody>
                本文介绍了PDO 未捕获异常 - 插入值列表与列列表不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我收到此异常

                Uncaught exception 'PDOException' with message 'SQLSTATE[21S01]: 
                Insert value list does not match column list: 1136 Column count doesn't match 
                value count at row 1
                

                使用此代码:

                $stmt = $conn->prepare('INSERT INTO project VALUES(:category, :title, :name)');
                      $stmt->execute(array(
                          ':category' => $_POST['category'],
                          ':title' => $_POST['title'],
                          ':name' => $_POST['name']
                ));
                

                错误信息是什么意思?

                推荐答案

                在查询中,指定要填充的列,例如:

                In your query, specify the columns that you want to populate, for example:

                $stmt = $conn->prepare('INSERT INTO project (category, title, name) VALUES(:category, :title, :name)');
                

                如果您不以这种方式指定列,则必须为表中的所有列包含一个值,这就是您收到错误的原因 - 因为表中还有其他列而您没有为它们明确指定一个值.

                If you don't specify the columns in that way, you have to include a value for all columns in the table, that's why you're getting the error - because there are other columns in the table and you haven't explicitly specified a value for them all.

                最好指定列,因为如果将来添加任何列或更改顺序,除非指定列列表,否则您的查询将中断.

                It is better to specify the columns because if any columns are added or the order is changed in future, your query will break unless the column list is specified.

                这篇关于PDO 未捕获异常 - 插入值列表与列列表不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:未定义变量:pdo,在 null 上调用成员函数 prepare( 下一篇:使用 PDO 插入多行

                相关文章

                最新文章

                  <small id='4KmRN'></small><noframes id='4KmRN'>

                  • <bdo id='4KmRN'></bdo><ul id='4KmRN'></ul>

                    <i id='4KmRN'><tr id='4KmRN'><dt id='4KmRN'><q id='4KmRN'><span id='4KmRN'><b id='4KmRN'><form id='4KmRN'><ins id='4KmRN'></ins><ul id='4KmRN'></ul><sub id='4KmRN'></sub></form><legend id='4KmRN'></legend><bdo id='4KmRN'><pre id='4KmRN'><center id='4KmRN'></center></pre></bdo></b><th id='4KmRN'></th></span></q></dt></tr></i><div id='4KmRN'><tfoot id='4KmRN'></tfoot><dl id='4KmRN'><fieldset id='4KmRN'></fieldset></dl></div>

                  1. <tfoot id='4KmRN'></tfoot>
                    <legend id='4KmRN'><style id='4KmRN'><dir id='4KmRN'><q id='4KmRN'></q></dir></style></legend>