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

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

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

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

      1. 函數內部的 mysqli/mysql 查詢不起作用

        mysqli/mysql query inside function not working(函數內部的 mysqli/mysql 查詢不起作用)

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

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

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

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

                  本文介紹了函數內部的 mysqli/mysql 查詢不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試為我的網站構建一些功能,其中一些包括從mysql數據庫中獲取數據.當我在函數之外測試代碼時它似乎工作正常.所以在這里,第一頁:

                  I'm tryin to build some functions for a website of mine and some of them consist in fetching data from the mysql database. When I test the code outside of the function it seems to work properly. So here it is, The first page:

                  require('db.php');
                  require('functions.php');
                  
                  $email = 'sample@gmail.com';
                  
                  if (user_exists($email) == true){
                   echo "Good news, this exists";
                  }
                  

                  現在 db.php :

                  Now db.php :

                  $db = new MySQLi("localhost","test","test","test");
                  if ($db->connect_errno){
                      echo "$db->connect_errno";
                  }
                  

                  還有functions.php文件:

                  And the functions.php file:

                  function sanitize ($data){
                      $db->mysqli_real_escape_string($data);
                  }
                  function user_exists($usermail){
                      $usermail = sanitize($usermail);
                      $query = $db->query("SELECT COUNT(userId) FROM users WHERE userEmail= '$usermail' ");
                      $check = $query->num_rows;
                      return ($check == 1) ? true : false;
                  }
                  

                  訪問第一個文件時遇到的錯誤是:

                  And the error I'm getting when accessing the first file is:

                  Notice: Undefined variable: db in C:xampphtdocsauctiorincfunctions.php on line 6
                  
                  Fatal error: Call to a member function query() on a non-object in C:xampphtdocsauctiorincfunctions.php on line 6
                  

                  所以我需要/包含了 db.php,其中 $db 是 mysqli 連接.在同一個文件(第一個文件)中,我調用位于 functions.php 的函數

                  SO I've required/included the db.php where $db is the mysqli connect. And within the same file(first file) I call the functions located at functions.php

                  先謝謝你,我很感激你的幫助,因為這讓我很生氣......

                  Thank you in advance, I'd appreciate your help as this is pissing me off......

                  推薦答案

                  你可能需要使用 global 關鍵字,否則 $db 被認為是局部范圍內的 var.

                  You probably need to use the global keyword, otherwise $db is considered a var in local scope.

                  function sanitize ($data){
                      global $db;
                      $db->mysqli_real_escape_string($data);
                  }
                  
                  function user_exists($usermail){
                      global $db;
                      $usermail = sanitize($usermail);
                      $query = $db->query("SELECT COUNT(userId) FROM users WHERE userEmail= '$usermail' ");
                      $check = $query->num_rows;
                      return ($check == 1) ? true : false;
                  }
                  

                  這篇關于函數內部的 mysqli/mysql 查詢不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中保持其類型?)
                  1. <tfoot id='7gPTD'></tfoot>

                        <legend id='7gPTD'><style id='7gPTD'><dir id='7gPTD'><q id='7gPTD'></q></dir></style></legend>

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

                        <small id='7gPTD'></small><noframes id='7gPTD'>

                          • <bdo id='7gPTD'></bdo><ul id='7gPTD'></ul>
                              <tbody id='7gPTD'></tbody>

                            主站蜘蛛池模板: 成人精品一区二区三区中文字幕 | www.国产视频 | 91在线最新 | 亚洲播放一区 | 国产精品久久久久国产a级 欧美日本韩国一区二区 | 久久久观看 | 91视频免费视频 | 色爱av| 91在线视频播放 | 久久亚洲视频网 | 视频在线亚洲 | 久久久久精 | 亚洲资源站| 毛片入口| 日韩美香港a一级毛片免费 国产综合av | 天天av天天好逼 | 成人免费视频7777777 | 欧美一级毛片在线播放 | 中文字幕免费视频 | 中文字幕亚洲欧美 | 一区二区三区四区视频 | 亚洲色图婷婷 | 99热热热热 | 欧美精品一区二区免费 | 一区二区三区av | 久久久久久成人 | 99色综合| 三级在线免费观看 | 中文一区| 国产精品久久九九 | 久草视频观看 | 国产亚洲一区二区三区 | 999热视频 | 亚洲精品高清视频在线观看 | 欧美aaaaaa| 成人午夜av | 色黄网站 | 欧美精品在线免费 | 狠狠av | 九九久久精品 | 成人精品福利 |