• <bdo id='3B36d'></bdo><ul id='3B36d'></ul>
    1. <tfoot id='3B36d'></tfoot>

      <legend id='3B36d'><style id='3B36d'><dir id='3B36d'><q id='3B36d'></q></dir></style></legend>

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

      1. <small id='3B36d'></small><noframes id='3B36d'>

        为什么当我将多个查询发送到 mysqli_query 时会发生

        时间:2023-07-29
      2. <i id='k5BzZ'><tr id='k5BzZ'><dt id='k5BzZ'><q id='k5BzZ'><span id='k5BzZ'><b id='k5BzZ'><form id='k5BzZ'><ins id='k5BzZ'></ins><ul id='k5BzZ'></ul><sub id='k5BzZ'></sub></form><legend id='k5BzZ'></legend><bdo id='k5BzZ'><pre id='k5BzZ'><center id='k5BzZ'></center></pre></bdo></b><th id='k5BzZ'></th></span></q></dt></tr></i><div id='k5BzZ'><tfoot id='k5BzZ'></tfoot><dl id='k5BzZ'><fieldset id='k5BzZ'></fieldset></dl></div>

      3. <small id='k5BzZ'></small><noframes id='k5BzZ'>

        <tfoot id='k5BzZ'></tfoot>
              <legend id='k5BzZ'><style id='k5BzZ'><dir id='k5BzZ'><q id='k5BzZ'></q></dir></style></legend>
                  <bdo id='k5BzZ'></bdo><ul id='k5BzZ'></ul>
                    <tbody id='k5BzZ'></tbody>

                  本文介绍了为什么当我将多个查询发送到 mysqli_query 时会发生错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  同样的请求在Adminer中没有错误,但是在php中是

                  The same request in the Adminer has no errors, but in php is

                  您的 SQL 语法有错误;检查手册对应于您的 MariaDB 服务器版本以使用正确的语法靠近 'SET @lastID = last_insert_id();插入p_messages(letter_id, user_id, messa' 在第 1 行).

                  You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET @lastID = last_insert_id(); INSERT INTO p_messages(letter_id, user_id, messa' at line 1).

                  PHP:

                  $DB->query("INSERT INTO p_letters(user_1_id, user_1_name, create_date) VALUES ('".htmlspecialchars($accountId)."', '".htmlspecialchars($username)."', now()); SET @lastID = LAST_INSERT_ID(); INSERT INTO p_messages(letter_id, user_id, message) VALUES (@lastID, '".htmlspecialchars($accountId)."', '".htmlspecialchars($text)."');");
                  

                  SQL:

                  INSERT INTO p_letters(user_1_id, user_1_name, create_date) VALUES ('acc583bfa62de6f66.05116379', '212312313', now()); SET @lastID = LAST_INSERT_ID(); INSERT INTO p_messages(letter_id, user_id, message) VALUES (@lastID, 'acc583bfa62de6f66.05116379', 'Проверка');
                  

                  推荐答案

                  您应该使用单独的 API 调用来运行查询.

                  You are supposed to run your queries with separate API calls.

                  $DB->query("INSERT INTO ...");
                  $DB->query("SET @lastID = LAST_INSERT_ID()");
                  $DB->query("INSERT INTO ...");
                  

                  请注意,这里实际上不需要第二个查询,因为可以直接使用 LAST_INSERT_ID().

                  note that you don't actually need the second query here as LAST_INSERT_ID() can be used directly.

                  此外,对于任何数据库交互,您都不应该使用名为HTML 特殊字符"的函数.您必须改用准备好的语句.

                  Besides, you should never use a function named "HTML speacial chars" for any database interaction. You have to use prepared statements instead.

                  请注意,使用 multi_query 的建议是不合理且具有误导性的,会导致很多问题.

                  Note that a suggestion to use multi_query is unjustified and misleading, causing a lot of problems.

                  这篇关于为什么当我将多个查询发送到 mysqli_query 时会发生错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:通过ajax调用加载mysqli php数据 下一篇:单击按钮时更新信息表

                  相关文章

                  最新文章

                • <legend id='cZJgj'><style id='cZJgj'><dir id='cZJgj'><q id='cZJgj'></q></dir></style></legend>

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

                    <tfoot id='cZJgj'></tfoot>
                      <bdo id='cZJgj'></bdo><ul id='cZJgj'></ul>

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