• <bdo id='DdjqS'></bdo><ul id='DdjqS'></ul>
    <legend id='DdjqS'><style id='DdjqS'><dir id='DdjqS'><q id='DdjqS'></q></dir></style></legend>
  1. <tfoot id='DdjqS'></tfoot>

      <small id='DdjqS'></small><noframes id='DdjqS'>

      <i id='DdjqS'><tr id='DdjqS'><dt id='DdjqS'><q id='DdjqS'><span id='DdjqS'><b id='DdjqS'><form id='DdjqS'><ins id='DdjqS'></ins><ul id='DdjqS'></ul><sub id='DdjqS'></sub></form><legend id='DdjqS'></legend><bdo id='DdjqS'><pre id='DdjqS'><center id='DdjqS'></center></pre></bdo></b><th id='DdjqS'></th></span></q></dt></tr></i><div id='DdjqS'><tfoot id='DdjqS'></tfoot><dl id='DdjqS'><fieldset id='DdjqS'></fieldset></dl></div>
    1. MYSQLI::prepare() ,使用占位符时出错:something

      时间:2023-07-29

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

      <legend id='guejN'><style id='guejN'><dir id='guejN'><q id='guejN'></q></dir></style></legend>
      1. <tfoot id='guejN'></tfoot>
      2. <small id='guejN'></small><noframes id='guejN'>

                <bdo id='guejN'></bdo><ul id='guejN'></ul>
                本文介绍了MYSQLI::prepare() ,使用占位符时出错:something的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我使用 mysqli,我看到了一些使用占位符的示例,例如 :something 和 ?

                我什么时候用过?它的工作原理,但是当我使用 :something 这样的查询

                <块引用>

                $sql = 插入食物(食物名称)值(:food_name)

                然后当我打电话时出现错误

                <块引用>

                $mysqli_object->prepare($sql);

                错误信息听起来像这样

                <块引用>

                用户错误!你有一个错误SQL 语法;检查手册对应于您的 MySQL 服务器使用正确语法的版本':food_name)' 附近

                但是当我使用?作为占位符,一切正常,我使用 PHP 5.3.1 和 MySQL 5.1.41

                我错过了什么地方,任何帮助将不胜感激,谢谢

                解决方案

                mysqli 不支持命名占位符.

                PDO 使用 bindParamexecute.

                (请注意,每个查询只能使用一次命名占位符.它们并不是非常有用.)

                hi im using mysqli and i saw some examples using placeholder like :something and ?

                when i used ? its working, but when i used :something in query like this

                $sql = INSERT INTO food(food_name) VALUES(:food_name)

                then error showed up when i called

                $mysqli_object->prepare($sql);

                error message sounds like this

                User Error! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':food_name)' at line

                but when i used ? as the placeholder, everything working well, i used PHP 5.3.1 and MySQL 5.1.41

                am i missed somewhere, any help will be appreciated thanks

                解决方案

                mysqli does not support named placeholders.

                PDO does, using either bindParam or execute.

                (Careful, you can only use a named placeholder once per query. They aren't too incredibly useful.)

                这篇关于MYSQLI::prepare() ,使用占位符时出错:something的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:mysqli 插入 - 但前提是不重复 下一篇:为什么此 SQL UPDATE 查询不适用于 WHERE 的变量?

                相关文章

                最新文章

                  <small id='IsxNl'></small><noframes id='IsxNl'>

                1. <legend id='IsxNl'><style id='IsxNl'><dir id='IsxNl'><q id='IsxNl'></q></dir></style></legend>
                  1. <tfoot id='IsxNl'></tfoot>
                      <bdo id='IsxNl'></bdo><ul id='IsxNl'></ul>

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