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

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

    <legend id='P7hEL'><style id='P7hEL'><dir id='P7hEL'><q id='P7hEL'></q></dir></style></legend>

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

        新的 Mysqli 对象为空

        时间:2023-07-29
              <legend id='u8yY4'><style id='u8yY4'><dir id='u8yY4'><q id='u8yY4'></q></dir></style></legend>

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

                <tbody id='u8yY4'></tbody>
                <bdo id='u8yY4'></bdo><ul id='u8yY4'></ul>

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

                  本文介绍了新的 Mysqli 对象为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在 PHP 中使用 Mysqli 创建到 MySQL 数据库的连接.当我在独立页面上执行以下代码时:

                  I'm trying to create a connection to a MySQL database using Mysqli in PHP. When I execute the following code on a stand alone page:

                  <?php
                  ini_set('display_errors', 'On');
                  error_reporting(E_ALL);
                  
                  $link = new mysqli('localhost', 'myuser', 'mypass', 'dbname');
                  var_dump($link);
                  

                  我得到的只是一个空的 Mysqli 对象,其中所有的属性都是空的.不会显示任何错误或任何内容.

                  All I get outputted is an empty Mysqli object where all the properties are null. No error or anything gets displayed.

                  我也没有在 Apache 或 MySQL 日志中看到任何条目.我有点不知所措.

                  I also don't see any entries in the Apache or MySQL logs. I'm kind of at a lost on this one.

                  推荐答案

                  我也遇到了这个问题,并且疯狂地尝试调试它.事实证明,有时出于某种原因,mysqli 对象没有被填充,但直接访问它的属性仍然会执行其背后的本机代码.因此,即使整个 mysqli 对象的 var_dump 显示空属性,如果您单独访问它们,它们也会存在.如果 errorno 结果为 false,则您可能执行了一个有效查询,但结果集为空,这是您不期望的.希望这会有所帮助.

                  I had this problem too and was going crazy trying to debug it. It turns out that sometimes for whatever reason the mysqli object does not get populated, but directly accessing it's properties still executes the native code behind it. So even though a var_dump of the entire mysqli object shows null properties, they are there if you access them individually. If errorno turns out to be false, you may have executed a valid query with an empty resultset that you weren't expecting. Hope this helps.

                  $mysqli = mysqli_connect('localhost', 'root', '', 'test', 3306);
                  
                  var_dump($mysqli);
                  
                  var_dump($mysqli->client_info);
                  var_dump($mysqli->client_version);
                  var_dump($mysqli->info);
                  

                  和输出:

                  object(mysqli)[1]
                    public 'affected_rows' => null
                    public 'client_info' => null
                    public 'client_version' => null
                    public 'connect_errno' => null
                    public 'connect_error' => null
                    public 'errno' => null
                    public 'error' => null
                    public 'field_count' => null
                    public 'host_info' => null
                    public 'info' => null
                  
                  
                  public 'insert_id' => null
                    public 'server_info' => null
                    public 'server_version' => null
                    public 'stat' => null
                    public 'sqlstate' => null
                    public 'protocol_version' => null
                    public 'thread_id' => null
                    public 'warning_count' => null
                  
                  string 'mysqlnd 5.0.8-dev - 20102224 - $Revision: 321634 $' (length=50)
                  int 50008
                  null
                  int 0
                  string 'localhost via TCP/IP' (length=20)
                  string '5.5.20-log' (length=10)
                  int 50520
                  

                  这篇关于新的 Mysqli 对象为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将使用 mysql_ 函数的脚本转换为使用 mysqli_ 下一篇:mysqli_query - 返回值

                  相关文章

                  最新文章

                  • <bdo id='8AGAq'></bdo><ul id='8AGAq'></ul>
                  <legend id='8AGAq'><style id='8AGAq'><dir id='8AGAq'><q id='8AGAq'></q></dir></style></legend>

                    <small id='8AGAq'></small><noframes id='8AGAq'>

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