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

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

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

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

      1. 如何處理重復條目的錯誤?

        How to handle error for duplicate entries?(如何處理重復條目的錯誤?)

          <tbody id='xx9cc'></tbody>
          • <bdo id='xx9cc'></bdo><ul id='xx9cc'></ul>

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

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

                  <legend id='xx9cc'><style id='xx9cc'><dir id='xx9cc'><q id='xx9cc'></q></dir></style></legend>
                  本文介紹了如何處理重復條目的錯誤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個 PHP 表單,可以將數據輸入到我的 MySQL 數據庫中.我的主鍵是用戶輸入的值之一.當用戶輸入表中已存在的值時,MySQL 錯誤Duplicate entry 'entered value' for key 1"被退回.而不是那個錯誤,我想提醒用戶他們需要輸入不同的值.只是一個回顯的消息或其他東西.

                  I have a PHP form that enters data into my MySQL database. My primary key is one of the user-entered values. When the user enters a value that already exists in the table, the MySQL error "Duplicate entry 'entered value' for key 1" is returned. Instead of that error, I would like to alert the user that they need to enter a different value. Just an echoed message or something.

                  如何將特定的 MySQL 錯誤轉換為 PHP 消息?

                  How to turn a specific MySQL error into a PHP message?

                  推薦答案

                  要檢查此特定錯誤,您需要找到 錯誤代碼.重復鍵是1062.然后使用 errno() 比較:

                  To check for this specific error, you need to find the error code. It is 1062 for duplicate key. Then use the result from errno() to compare with:

                  mysqli_query('INSERT INTO ...');
                  if (mysqli_errno() == 1062) {
                      print 'no way!';
                  }
                  

                  關于編程風格的說明
                  您應該始終設法避免使用幻數(我知道,我是在這個答案中介紹它的人).相反,您可以將已知錯誤代碼 (1062) 分配給一個常量(例如 MYSQLI_CODE_DUPLICATE_KEY).這將使您的代碼更易于維護,因為 if 語句中的條件在 1062 的含義從記憶中消失后的幾個月內仍然可讀:)

                  A note on programming style
                  You should always seek to avoid the use of magic numbers (I know, I was the one to introduce it in this answer). Instead, you could assign the known error code (1062) to a constant (e.g. MYSQLI_CODE_DUPLICATE_KEY). This will make your code easier to maintain as the condition in the if statement is still readable in a few months when the meaning of 1062 has faded from memory :)

                  這篇關于如何處理重復條目的錯誤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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的訪問被拒絕)

                  <legend id='8KcXX'><style id='8KcXX'><dir id='8KcXX'><q id='8KcXX'></q></dir></style></legend>
                    <tbody id='8KcXX'></tbody>

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

                    1. <small id='8KcXX'></small><noframes id='8KcXX'>

                        <bdo id='8KcXX'></bdo><ul id='8KcXX'></ul>
                          <tfoot id='8KcXX'></tfoot>

                            主站蜘蛛池模板: 狠狠干天天干 | 亚洲高清免费 | 97人澡人人添人人爽欧美 | 亚洲精品久久国产高清情趣图文 | 欧美日韩成人网 | 午夜精品久久 | 国产伦一区二区三区视频 | 欧美一级艳情片免费观看 | 99视频在线播放 | 狠狠久 | 亚洲第一福利网 | www免费视频| 一区二区三区小视频 | 特级生活片 | 精品视频在线一区 | 成年人网站国产 | 精品国产91亚洲一区二区三区www | 国产精品一区二区三区在线 | 777zyz色资源站在线观看 | av男人天堂影院 | 欧美激情综合网 | 波多野吉衣在线播放 | 中文字幕日韩一区 | 欧美日韩中文字幕 | 欧美精品91| 国产日韩欧美在线播放 | 日韩电影中文字幕 | 午夜影院在线观看版 | 91视频a| 久久不卡 | 97国产超碰 | 日本三级电影在线免费观看 | 国产欧美一区二区三区在线看 | 中文字幕一区二区三区精彩视频 | 天天躁日日躁狠狠躁白人 | 午夜精品在线观看 | 91精品一区二区三区久久久久 | 国产在线观看av | 一区二区视频在线 | 日本午夜视频 | 午夜久久 |