久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='Bo9x0'></small><noframes id='Bo9x0'>

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

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

        PDO:在非對象上調用成員函數 fetch()?

        PDO: Call to a member function fetch() on a non-object?(PDO:在非對象上調用成員函數 fetch()?)

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

            <tbody id='WXa3E'></tbody>
        1. <legend id='WXa3E'><style id='WXa3E'><dir id='WXa3E'><q id='WXa3E'></q></dir></style></legend>

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

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

                • 本文介紹了PDO:在非對象上調用成員函數 fetch()?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我只是在嘗試 PDO 并且收到此錯誤,致命錯誤:在非對象上調用成員函數 fetch(),但它不是已經在 $this->db 對象上了嗎?

                  I am just trying out PDO and I get this error, Fatal error: Call to a member function fetch() on a non-object, but isn't it already on the $this->db object?

                  class shoutbox {
                  
                      private $db;
                  
                      function __construct($dbname, $username, $password, $host = "localhost" ) 
                      { # db conections
                          try {
                              $this->db = new PDO("mysql:host=".$hostname.";dbname=".$dbname, $username, $password);
                          }
                          catch(PDOException $e)
                          {
                              echo $e->getMessage();
                          }
                      }
                  
                      function getShouts()
                      {
                          $sql_shouts = $this->db->query('SELECT shoutid, message, pmuserid, ipadress, time FROM shouts WHERE pmuserid == 0');
                  
                          return $sql_shouts->fetch(PDO::FETCH_OBJ);
                  
                      }
                  
                  }
                  

                  推薦答案

                  仔細查看 PDO::query,特別是返回值"部分:

                  Look carefully at the documentation for PDO::query, particularly the "Return Values" section:

                  PDO::query() 返回一個 PDOStatement對象,或失敗時為 FALSE.

                  PDO::query() returns a PDOStatement object, or FALSE on failure.

                  重要的一點是失敗時為 FALSE".FALSE 不是一個對象,所以調用 ->fetch() 是個壞消息.

                  The important bit is "FALSE on failure". FALSE is not an object, so calling ->fetch() is bad news.

                  該錯誤可能是由于您使用了=="比較運算符.在 SQL 中,它只是=".

                  The error is probably due to your use of "==" comparison operator. In SQL, it's just "=".

                  你應該測試 $sql_shouts 是不是假的,然后對錯誤做一些聰明的事情,如果有的話:

                  You should test that the $sql_shouts is not false, and then do something smart with the error, if there was one:

                  <?PHP
                  $sql_shouts = $this->db->query('...');
                  if ($sql_shouts === false){
                      $errorInfo = $this->db->errorInfo();
                      //log the error or take some other smart action
                  }
                  return $sql_shouts->fetch(PDO::FETCH_OBJ);
                  

                  這篇關于PDO:在非對象上調用成員函數 fetch()?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                • <tfoot id='ei6O8'></tfoot>

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

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

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

                          1. 主站蜘蛛池模板: 一区二区中文字幕 | 国产精品久久二区 | 国产精品美女www | 国产亚洲第一页 | 久久久久久亚洲欧洲 | 午夜av成人| 中文字幕视频在线观看 | 日韩视频一区二区在线 | 青青草网 | 在线观看一区 | 日韩在线观看网站 | 日韩成人国产 | 黄色毛片网站在线观看 | 超碰人人人 | 久久精品中文 | 国产亚洲精品久久19p | 二区在线观看 | 在线免费观看毛片 | 一级片免费视频 | 9999国产精品欧美久久久久久 | 国产乱码精品一区二区三区五月婷 | 在线观看中文字幕 | 婷婷五月色综合 | 国产欧美一区二区三区另类精品 | 爱爱免费视频网站 | 一区二区在线 | 久久国产精品久久久久久 | 国产精品日韩欧美一区二区三区 | 久久成人免费视频 | 91中文在线观看 | 欧美天堂| 国产第一亚洲 | 成人久久久久 | 密色视频| 羞羞视频一区二区 | 羞羞色影院 | 91在线观看视频 | 精品国产18久久久久久二百 | 伊人一区 | 久久久久久亚洲精品 | 国产精品欧美一区二区三区不卡 |