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

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

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

      致命错误:在非对象上调用成员函数 fetch_assoc()

      时间:2023-07-31
        <bdo id='zBXKm'></bdo><ul id='zBXKm'></ul>

        <tfoot id='zBXKm'></tfoot>
      • <legend id='zBXKm'><style id='zBXKm'><dir id='zBXKm'><q id='zBXKm'></q></dir></style></legend>

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

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

              • 本文介绍了致命错误:在非对象上调用成员函数 fetch_assoc()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试执行一些查询以获取有关某些图像的信息页面.我写了一个函数

                I'm trying to execute a few queries to get a page of information about some images. I've written a function

                function get_recent_highs($view_deleted_images=false)
                {
                    $lower = $this->database->conn->real_escape_string($this->page_size * ($this->page_number - 1));
                    $query = "SELECT image_id, date_uploaded FROM `images` ORDER BY ((SELECT SUM( image_id=`images`.image_id ) FROM `image_votes` AS score) / (SELECT DATEDIFF( NOW( ) , date_uploaded ) AS diff)) DESC LIMIT " . $this->page_size . " OFFSET $lower"; //move to database class
                    $result = $this->database->query($query);
                    $page = array();
                    while($row = $result->fetch_assoc())
                    {
                        try
                        {
                            array_push($page, new Image($row['image_id'], $view_deleted_images));
                        }
                        catch(ImageNotFoundException $e)
                        {
                            throw $e;
                        }
                    }
                    return $page;
                }
                

                根据它们的受欢迎程度选择这些图像的页面.我编写了一个处理与数据库交互的 Database 类和一个保存图像信息的 Image 类.当我尝试运行此程序时出现错误.

                that selects a page of these images based on their popularity. I've written a Database class that handles interactions with the database and an Image class that holds information about an image. When I attempt to run this I get an error.

                Fatal error: Call to a member function fetch_assoc() on a non-object
                

                $result 是一个 mysqli 结果集,所以我很困惑为什么这不起作用.

                $result is a mysqli resultset, so I'm baffled as to why this isn't working.

                推荐答案

                那是因为您的查询中有错误.MySQli->query()出错时返回false.将其更改为类似::

                That's because there was an error in your query. MySQli->query() will return false on error. Change it to something like::

                $result = $this->database->query($query);
                if (!$result) {
                    throw new Exception("Database Error [{$this->database->errno}] {$this->database->error}");
                }
                

                如果有错误应该抛出异常...

                That should throw an exception if there's an error...

                这篇关于致命错误:在非对象上调用成员函数 fetch_assoc()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:警告:mysqli_query() 期望参数 1 是 mysqli,在 下一篇:为什么mysqli num_rows 总是返回0?

                相关文章

                最新文章

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

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

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

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