久久久久久久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 顯示用戶(hù)名和密碼

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

      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 顯示用戶(hù)名和密碼的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  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 無(wú)法連接到主機(jī),fatal error 會(huì)顯示用戶(hù)名和密碼.

                  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 中關(guān)閉 display_error=0,但這樣我就無(wú)法知道當(dāng)我的主機(jī)沒(méi)有響應(yīng)時(shí).

                  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.

                  有沒(méi)有辦法修改錯(cuò)誤信息?

                  Is there a way I can modify the error message?

                  推薦答案

                  錯(cuò)誤處理和錯(cuò)誤報(bào)告之間存在差異.

                  There is a difference between error handling and error reporting.

                  • 錯(cuò)誤處理是防止您的最終用戶(hù)看到任何堆棧跟蹤、重要信息或自動(dòng)生成的錯(cuò)誤消息的過(guò)程.它還可以通過(guò)使用 try catch 塊來(lái)修改腳本的運(yùn)行方式.
                  • 錯(cuò)誤報(bào)告定義了給定腳本將報(bào)告哪些信息.
                  • 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.

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

                  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.

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

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

                  錯(cuò)誤寫(xiě)在文件error_log 中,該文件通常與您的index.php(或任何直接調(diào)用的PHP 文件)位于同一級(jí)別.您也可以從您的 cPanel 訪(fǎng)問(wèn)它.

                  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.

                  您的錯(cuò)誤可能未被捕獲,因?yàn)槟拇a位于命名空間中,而您想要捕獲全局命名空間 PDOException.使用 指示您正在尋找全局 PDOException 的腳本.一旦發(fā)現(xiàn)錯(cuò)誤,就可以使用 的常規(guī)方法回顯您想要的內(nèi)容PDOException 類(lèi).

                  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;
                      }
                  }
                  

                  這會(huì)向您發(fā)送一封郵件,其中包含錯(cuò)誤的痕跡,防止您的用戶(hù)在告訴您出現(xiàn)問(wèn)題時(shí)看到它.

                  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 語(yǔ)句返回的錯(cuò)誤代碼.

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

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

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

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動(dòng)游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個(gè)值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動(dòng)程序)
                      <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>

                            主站蜘蛛池模板: 成人午夜在线 | 久久综合一区二区三区 | 91久久精品国产91久久 | 亚洲一二三区免费 | 91麻豆精品国产91久久久久久久久 | 国产免费一区 | 一区二区久久电影 | 91精品国产一二三 | 日韩a级片 | 中文字幕在线免费视频 | 九九综合| 亚洲成av | 久久中文字幕一区 | 中文字幕日韩欧美 | 欧美在线一区二区三区 | 成人精品| 午夜电影网 | 男人久久天堂 | 尤物在线精品视频 | 亚洲免费在线观看 | 成人在线视频免费播放 | 国产欧美在线一区 | 中文字幕99| 亚洲综合中文字幕在线观看 | 亚洲视频区| 欧美日韩大片 | 久久精品亚洲 | 九九久久精品 | 一区二区三区视频在线观看 | 日韩av中文 | 国产精品一区三区 | 久久福利电影 | 亚洲精品一区二区 | 91久久久久久久久久久 | 成人久久网 | 欧美a在线| 色狠狠一区 | 4hu最新网址 | 欧美成人激情视频 | 成人免费福利 | 久久这里只有精品首页 |