<tfoot id='IPKYK'></tfoot>

    • <bdo id='IPKYK'></bdo><ul id='IPKYK'></ul>

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

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

        <legend id='IPKYK'><style id='IPKYK'><dir id='IPKYK'><q id='IPKYK'></q></dir></style></legend>
      1. mysqli_query(): 无法获取 mysqli 错误

        时间:2023-07-31
          <tfoot id='zuSEi'></tfoot>

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

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

                  <i id='zuSEi'><tr id='zuSEi'><dt id='zuSEi'><q id='zuSEi'><span id='zuSEi'><b id='zuSEi'><form id='zuSEi'><ins id='zuSEi'></ins><ul id='zuSEi'></ul><sub id='zuSEi'></sub></form><legend id='zuSEi'></legend><bdo id='zuSEi'><pre id='zuSEi'><center id='zuSEi'></center></pre></bdo></b><th id='zuSEi'></th></span></q></dt></tr></i><div id='zuSEi'><tfoot id='zuSEi'></tfoot><dl id='zuSEi'><fieldset id='zuSEi'></fieldset></dl></div>
                  本文介绍了mysqli_query(): 无法获取 mysqli 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我尝试从文本文件导入数据时,我在以下函数中收到无法获取 mysqli"错误.然而,插入功能在其他地方工作得很好.文件中的数据被正确解析,当我将其复制并粘贴到 PHPMyAdmin 时,查询工作正常.

                  I am receiving a "Couldn't fetch mysqli" error on the following function when trying to import data from a text file. However the insert function is working just fine in other places. The data from the file is being parsed correctly, and the query works fine when I copy and past it into PHPMyAdmin.

                  功能

                  1. $conn = mysqli_connect("localhost","xxxxx","xxxxx","xxxx") OR die("Error!!");
                  2. function insert ($query){
                  3.  global $conn;
                  4.  if (!$conn) {
                  5.          die("Connection failed: " . mysqli_connect_error());
                  6.  }
                  7.  if (mysqli_query($conn, $query)){
                  8.      $result = "<b>Inserted $query</b>
                  <br />";
                  9.      return $result;
                  10. } else {
                  11.     echo "Error: ". $query . "<br />" . mysqli_error($conn);
                  12. }
                  13. 
                  14. mysqli_close($conn);
                  15. }
                  

                  我要插入的查询是:

                  INSERT INTO movies VALUES( '2603', 'Miracle Season, The', 'The Miracle Season', '2019-04-01',
                  '2D', '9', '101', '10', 'PG', 'for some thematic elements.', '', 'Scope', '01:30:55' )
                  

                  我通过 $result = insert($query); 调用函数;

                  I am calling the function by $result = insert($query);

                  无法获取 mysqli"错误在第 7 行.我也在第 11 行和第 14 行收到错误.

                  The "couldn't fetch mysqli" error is on line 7. I'm also getting the error on line 11 and line 14.

                  正如我上面所说,该函数与其他脚本一起运行良好,当我尝试手动运行时,查询运行良好.

                  As I said above, the function is working fine with other scripts and the query works fine when I try to run it manually.

                  另外一个注意事项是插入的项目不包含自动递增 id,因为查询的第一个值已经是来自另一个数据库的唯一 id.我的导入函数检查 id 以查看它是否已经存在,并根据行是否存在运行更新或插入查询.

                  One additional note is the inserted items do not contain an auto increment id because the first value of the query is already a unique id from another database. My import function checks the id to see if it already exists and runs an update or insert query depending on whether the row exists.

                  推荐答案

                  我怀疑您多次调用该函数.但是它在最后调用了mysqli_close($conn),所以当你下次尝试使用它时出现错误,因为$conn不能使用任何更多.

                  I suspect you're calling the function multiple times. But it calls mysqli_close($conn) at the end, so when you try to use it the next time you get an error, because $conn can't be used any more.

                  去掉那一行,用 MySQL 脚本全部完成后关闭连接(或者不用管,脚本结束时它会自动关闭).

                  Get rid of that line, and close the connection when the script is all done using MySQL (or don't bother, it will be closed automatically when the script ends).

                  这篇关于mysqli_query(): 无法获取 mysqli 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:MySQLi 准备语句与 IN 运算符 下一篇:无法在给定上下文中返回结果集

                  相关文章

                  最新文章

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

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

                    1. <small id='tBMcw'></small><noframes id='tBMcw'>