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

    1. <small id='quDqP'></small><noframes id='quDqP'>

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

        未捕獲的 PDOException 顯示用戶名和密碼

        Uncaught PDOException reveals username and password(未捕獲的 PDOException 顯示用戶名和密碼)

      2. <legend id='NJvHy'><style id='NJvHy'><dir id='NJvHy'><q id='NJvHy'></q></dir></style></legend>
          • <bdo id='NJvHy'></bdo><ul id='NJvHy'></ul>
              <tbody id='NJvHy'></tbody>

            1. <small id='NJvHy'></small><noframes id='NJvHy'>

                <tfoot id='NJvHy'></tfoot>

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

                • 本文介紹了未捕獲的 PDOException 顯示用戶名和密碼的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  try {
                      self::$dbinstance = new PDO(
                          "mysql:host=$c[host];dbname=$c[dbname]", $c['user'], $c['password']
                      );
                  
                      self::$dbinstance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                  } 
                  catch(PDOException $e) {
                      echo "Errors" . $e->getMessage();
                  }
                  

                  在上面的代碼中,如果 PDO 無法連接到主機,fatal error 會顯示用戶名和密碼.

                  In the above code, if PDO fails to connect to the host, a fatal error reveals the username and password.

                  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003]
                  Can't connect to MySQL server on '172.25.102.65' (10060)' in
                  D:xampphtdocsmytestwh_client_2.1classesimportmodule-class.php:33 Stack trace: #0
                  D:xampphtdocsmytestwh_client_2.1classesimportmodule-class.php(33): PDO-
                  >__construct('mysql:host=172....', 'host', 'password') #1
                  

                  一種可能的方法是在 php.ini 中關閉 display_error=0,但這樣我就無法知道當我的主機沒有響應時.

                  One possible way is to turn the display_error=0 off in php.ini, but this way I won't able to know that when my host is not responding.

                  有沒有辦法修改錯誤信息?

                  Is there a way I can modify the error message?

                  推薦答案

                  錯誤處理和錯誤報告之間存在差異.

                  There is a difference between error handling and error reporting.

                  • 錯誤處理是防止您的最終用戶看到任何堆棧跟蹤、重要信息或自動生成的錯誤消息的過程.它還可以通過使用 try catch 塊來修改腳本的運行方式.
                  • 錯誤報告定義了給定腳本將報告哪些信息.
                  • Error handling is the process of preventing your end users to see any stack trace, vital information or automatically generated error messages. It can also modify the way your script runs by using a try catch block.
                  • Error reporting defines which information will be reported by a given script.

                  為了正確處理錯誤,我認為 ini_set('display_errors',0); 是更好的方法.您不希望屏幕上顯示任何錯誤消息.

                  To handle errors properly, I think that ini_set('display_errors',0); is the better approach. You do not want any error message displaying on the screen.

                  但是,我想獲得所有可能的錯誤信息,所以我使用了error_reporting(E_ALL);.

                  However, I want to have all possible information on errors, so I use error_reporting(E_ALL);.

                  錯誤寫在文件error_log 中,該文件通常與您的index.php(或任何直接調用的PHP 文件)位于同一級別.您也可以從您的 cPanel 訪問它.

                  Errors are written in a file, error_log, which usually resides at the same level as your index.php (or any PHP file called directly). You can also access it from your cPanel.

                  您的錯誤可能未被捕獲,因為您的代碼位于命名空間中,而您想要捕獲全局命名空間 PDOException.使用 指示您正在尋找全局 PDOException 的腳本.一旦發現錯誤,就可以使用 的常規方法回顯您想要的內容PDOException 類.

                  Your error is probably uncaught because your code is in a namespace, whereas you want to catch the global namespace PDOException. Use a to indicate your script you're looking for the global PDOException. Once you catch your error, you can echo the content you want, using the normal methods of the PDOException class.

                  try {
                      $db = new PDO (/*connection infos*/);
                  }
                  catch (PDOException $e) {
                      switch ($e->errorCode()) {
                          case 'HY000':
                          // Or whatever error you are looking for
                          // here it's the general error code
                              mail('your@email.com','connection problem',$e->getTraceAsString());
                              $db = new PDO (/*rollback connection infos of a local database*/);
                              break;
                      }
                  }
                  

                  這會向您發送一封郵件,其中包含錯誤的痕跡,防止您的用戶在告訴您出現問題時看到它.

                  That would send you a mail, containing the trace of the error, preventing your user from seeing it while telling you something is wrong.

                  這里是參考 用于 PDO 語句返回的錯誤代碼.

                  Here is the reference for the error codes returned by PDO statements.

                  這篇關于未捕獲的 PDOException 顯示用戶名和密碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                      <bdo id='xAv3Z'></bdo><ul id='xAv3Z'></ul>

                            <tbody id='xAv3Z'></tbody>
                          <legend id='xAv3Z'><style id='xAv3Z'><dir id='xAv3Z'><q id='xAv3Z'></q></dir></style></legend>

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

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

                            主站蜘蛛池模板: 亚洲国产精品视频一区 | 久热精品视频 | 操久久| 久久综合影院 | 伊人精品在线 | 欧美日韩一区二区三区四区 | 黄色片网站国产 | 伊人精品在线视频 | 久久中文免费视频 | 在线午夜| 欧美精品一区久久 | 亚洲第一区国产精品 | 中文字幕在线剧情 | 成人午夜av | 色婷婷综合网站 | 亚洲第一福利网 | 久久久久久久国产精品视频 | 91看片网| 一区二区三区四区国产 | 国产精品国色综合久久 | 国产高清在线 | 国产一级免费视频 | 日韩在线观看一区 | 国产三级电影网站 | 成年人在线视频 | 美女视频黄的免费 | 成人在线免费电影 | 国产三级日本三级 | 国产激情偷乱视频一区二区三区 | 福利av在线 | 中国一级毛片免费 | 91精品国产麻豆 | 欧美一区在线视频 | 羞羞色网站| 久久视频精品 | 特级丰满少妇一级aaaa爱毛片 | 中文字幕精品一区二区三区精品 | 天天看夜夜 | 国产精品久久久久久一区二区三区 | 国内av在线 | 亚洲国产情侣自拍 |