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

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

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

    1. 在準備好的語句上使用 fetch_assoc (php mysqli)

      Using fetch_assoc on prepared statements (php mysqli)(在準備好的語句上使用 fetch_assoc (php mysqli))
        • <legend id='9vhPg'><style id='9vhPg'><dir id='9vhPg'><q id='9vhPg'></q></dir></style></legend>

          <small id='9vhPg'></small><noframes id='9vhPg'>

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

              1. <tfoot id='9vhPg'></tfoot>
                本文介紹了在準備好的語句上使用 fetch_assoc (php mysqli)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我目前正在編寫一個登錄腳本,我得到了這個代碼:

                I'm currently working on a login script, and I got this code:

                $selectUser = $db->prepare("SELECT `id`,`password`,`salt` FROM `users` WHERE `username`=?");
                $selectUser->bind_param('s', $username);
                $selectUser->execute();
                
                if ($selectUser->num_rows() < 0)
                    echo "no_user";
                else
                {
                    $user = $selectUser->fetch_assoc();
                    echo $user['id'];
                }
                

                這是我得到的錯誤:

                致命錯誤:未捕獲的錯誤:調用未定義的方法mysqli_stmt::fetch_assoc()

                Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc()

                我嘗試了各種變體,例如:

                I tried all sorts of variations, like:

                $result = $selectUser->execute();
                $user = $result->fetch_assoc();
                

                還有更多……沒有任何效果.

                and more... nothing worked.

                推薦答案

                那是因為 fetch_assoc 不是 mysqli_stmt 對象的一部分.fetch_assoc 屬于 mysqli_result 類.可以使用mysqli_stmt::get_result先獲取一個結果對象,然后調用fetch_assoc:

                That's because fetch_assoc is not part of a mysqli_stmt object. fetch_assoc belongs to the mysqli_result class. You can use mysqli_stmt::get_result to first get a result object and then call fetch_assoc:

                $selectUser = $db->prepare("SELECT `id`,`password`,`salt` FROM `users` WHERE `username`=?");
                $selectUser->bind_param('s', $username);
                $selectUser->execute();
                $result = $selectUser->get_result();
                $assoc = $result->fetch_assoc();
                

                或者,您可以使用 bind_result 將查詢的列綁定到變量并使用 fetch() 代替:

                Alternatively, you can use bind_result to bind the query's columns to variables and use fetch() instead:

                $selectUser = $db->prepare("SELECT `id`,`password`,`salt` FROM `users` WHERE `username`=?");
                $selectUser->bind_param('s', $username);
                $selectUser->bind_result($id, $password, $salt);
                $selectUser->execute();
                while($selectUser->fetch())
                {
                    //$id, $password and $salt contain the values you're looking for
                }
                

                這篇關于在準備好的語句上使用 fetch_assoc (php mysqli)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                PHP Prepared Statement Problems(PHP 準備好的語句問題)
                mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
              2. <small id='sK6Fa'></small><noframes id='sK6Fa'>

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

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

                        • 主站蜘蛛池模板: 久久九九色 | 久久久久久久久91 | 玖玖爱365 | 玖玖色在线视频 | 一级片视频免费 | 91 久久 | 狠狠操电影 | 亚洲福利一区 | 国产色婷婷精品综合在线手机播放 | 日韩在线免费电影 | 国产色在线 | 国产一级电影在线观看 | 亚洲国产一区二区在线 | 黄色中文字幕 | 成人精品一区亚洲午夜久久久 | 91久久国产综合久久 | 一级黄色片一级黄色片 | 久久久久久免费毛片精品 | 国产精品网址 | 999精品视频在线观看 | 成人精品鲁一区一区二区 | 亚洲 欧美 日韩 精品 | 欧美天堂在线 | 黄色小视频入口 | 国产一二区免费视频 | 精品视频一区二区 | 亚洲精品区 | 国产精品视频97 | 精品毛片在线观看 | 三级在线免费 | 天天拍夜夜爽 | 我我色综合| 影音先锋成人资源 | 久久精品青青大伊人av | 日韩蜜桃视频 | 91九色视频 | 人人cao| 欧美日韩在线一区二区 | 狠狠色综合网站久久久久久久 | 欧美不卡视频 | 国产在线麻豆精品入口 |