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

  1. <small id='4gJxF'></small><noframes id='4gJxF'>

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

    <legend id='4gJxF'><style id='4gJxF'><dir id='4gJxF'><q id='4gJxF'></q></dir></style></legend>
        <bdo id='4gJxF'></bdo><ul id='4gJxF'></ul>
    1. <tfoot id='4gJxF'></tfoot>

      PHP/MySQL 有編碼問題

      PHP/MySQL with encoding problems(PHP/MySQL 有編碼問題)
      <i id='EbsMT'><tr id='EbsMT'><dt id='EbsMT'><q id='EbsMT'><span id='EbsMT'><b id='EbsMT'><form id='EbsMT'><ins id='EbsMT'></ins><ul id='EbsMT'></ul><sub id='EbsMT'></sub></form><legend id='EbsMT'></legend><bdo id='EbsMT'><pre id='EbsMT'><center id='EbsMT'></center></pre></bdo></b><th id='EbsMT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EbsMT'><tfoot id='EbsMT'></tfoot><dl id='EbsMT'><fieldset id='EbsMT'></fieldset></dl></div>

        <bdo id='EbsMT'></bdo><ul id='EbsMT'></ul>
          1. <small id='EbsMT'></small><noframes id='EbsMT'>

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

            1. <tfoot id='EbsMT'></tfoot>
                <tbody id='EbsMT'></tbody>

                本文介紹了PHP/MySQL 有編碼問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我在使用 PHP 時遇到了編碼問題.

                I am having trouble with PHP regarding encoding.

                我有一個 JavaScript/jQuery HTML5 頁面使用 $.post 與我的 PHP 腳本交互.但是,PHP 面臨著一個奇怪的問題,可能與編碼有關.

                I have a JavaScript/jQuery HTML5 page interact with my PHP script using $.post. However, PHP is facing a weird problem, probably related to encoding.

                當我寫

                htmlentities("í")
                

                我希望 PHP 輸出 &iacute;.但是,它會輸出 &Atilde;&shy;一開始,我以為我在編碼上犯了一些錯誤,但是

                I expect PHP to output &iacute;. However, instead it outputs &Atilde;&shy; At the beginning, I thought that I was making some mistake with the encodings, however

                htmlentities("í")=="&iacute;"?"Good":"Fail";
                

                正在輸出失敗",其中

                htmlentities("í")=="&Atilde;&shy;"?"Good":"Fail";
                

                但是 htmlentities($search, null, "utf-8") 按預期工作.

                我想讓 PHP 與 MySQL 服務器通信,但它也有編碼問題,即使我使用 utf8_encode.我該怎么辦?

                I want to have PHP communicate with a MySQL server, but it has encoding problems too, even if I use utf8_encode. What should I do?

                在 SQL 命令上,寫

                On the SQL command, writing

                SELECT id,uid,type,value FROM users,profile
                WHERE uid=id AND type='name' AND value='XXX';
                

                其中 XXX 不包含 í 字符,按預期工作,但如果有任何 'í' 字符,則不會.

                where XXX contains no í chars, works as expected, but it does not if there is any 'í' char.

                SET NAMES 'utf8';
                SET CHARACTER SET 'utf8';
                SELECT id,uid,type,value FROM users,profile
                WHERE uid=id AND type='name' AND value='XXX';
                

                不僅對于í字符失敗,而且對于沒有任何特殊"字符的字符串也會失敗.從 SET NAMES 和 SET CHARACTER SET 中刪除 ' 字符似乎沒有任何改變.

                Not only fails for í chars, but it ALSO fails for strings without any 'special' characters. Removing the ' chars from SET NAMES and SET CHARACTER SET doesn't seem to change anything.

                我正在使用 PDO 連接到 MySQL 數據庫.

                I am connecting to the MySQL database using PDO.

                編輯 2:我使用的是 XAMPP for Linux 的 MySQL 5.1.30 版.

                EDIT 2: I am using MySQL version 5.1.30 of XAMPP for Linux.

                編輯 3:從 PhpMyAdmin 輸出運行 SHOW VARIABLES LIKE '%character%'

                EDIT 3: Running SHOW VARIABLES LIKE '%character%' from PhpMyAdmin outputs

                character_set_client    utf8
                character_set_connection    utf8
                character_set_database  latin1
                character_set_filesystem    binary
                character_set_results   utf8
                character_set_server    latin1
                character_set_system    utf8
                character_sets_dir  /opt/lampp/share/mysql/charsets/
                

                從我的 PHP 腳本(使用 print_r)輸出運行相同的查詢:

                Running the same query from my PHP script(with print_r) outputs:

                Array
                (
                    [0] => Array
                        (
                            [Variable_name] => character_set_client
                            [0] => character_set_client
                            [Value] => latin1
                            [1] => latin1
                        )
                
                    [1] => Array
                        (
                            [Variable_name] => character_set_connection
                            [0] => character_set_connection
                            [Value] => latin1
                            [1] => latin1
                        )
                
                    [2] => Array
                        (
                            [Variable_name] => character_set_database
                            [0] => character_set_database
                            [Value] => latin1
                            [1] => latin1
                        )
                
                    [3] => Array
                        (
                            [Variable_name] => character_set_filesystem
                            [0] => character_set_filesystem
                            [Value] => binary
                            [1] => binary
                        )
                
                    [4] => Array
                        (
                            [Variable_name] => character_set_results
                            [0] => character_set_results
                            [Value] => latin1
                            [1] => latin1
                        )
                
                    [5] => Array
                        (
                            [Variable_name] => character_set_server
                            [0] => character_set_server
                            [Value] => latin1
                            [1] => latin1
                        )
                
                    [6] => Array
                        (
                            [Variable_name] => character_set_system
                            [0] => character_set_system
                            [Value] => utf8
                            [1] => utf8
                        )
                
                    [7] => Array
                        (
                            [Variable_name] => character_sets_dir
                            [0] => character_sets_dir
                            [Value] => /opt/lampp/share/mysql/charsets/
                            [1] => /opt/lampp/share/mysql/charsets/
                        )
                
                )
                

                運行

                SET NAMES 'utf8';
                SET CHARACTER SET 'utf8';
                SHOW VARIABLES LIKE '%character%'
                

                輸出一個空數組.

                推薦答案

                指定htmlentities<的編碼很重要/a> 匹配輸入,就像您在最后一個示例中所做的那樣,但在前三個示例中省略了.

                It's very important to specify the encoding of htmlentities to match that of the input, as you did in your final example but omitted in the first three.

                htmlentities($text,ENT_COMPAT,'utf-8');
                

                關于與 MySQL 的通信,您需要確保連接排序規則和字符集與您正在傳輸的數據匹配.您可以在配置文件中進行設置,也可以在運行時使用以下查詢進行設置:

                Regarding communications with MySQL, you need to make sure the connection collation and character set matches the data you are transmitting. You can either set this in the configuration file, or at runtime using the following queries:

                SET NAMES utf8;
                SET CHARACTER SET utf8;
                

                確保表、數據庫和服務器字符集也匹配.有一種設置不能在運行時更改,那就是服務器的字符集.需要在配置文件中修改:

                Make sure the table, database and server character sets match as well. There is one setting you can't change at run-time, and that's the server's character set. You need to modify it in the configuration file:

                [mysqld]
                character-set-server = utf8
                default-character-set = utf8 
                skip-character-set-client-handshake
                

                閱讀更多關于 MySQL 中的字符集和排序規則在手冊中.

                Read more on characters sets and collations in MySQL in the manual.

                這篇關于PHP/MySQL 有編碼問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                    • <small id='gKKaz'></small><noframes id='gKKaz'>

                          <bdo id='gKKaz'></bdo><ul id='gKKaz'></ul>

                          <i id='gKKaz'><tr id='gKKaz'><dt id='gKKaz'><q id='gKKaz'><span id='gKKaz'><b id='gKKaz'><form id='gKKaz'><ins id='gKKaz'></ins><ul id='gKKaz'></ul><sub id='gKKaz'></sub></form><legend id='gKKaz'></legend><bdo id='gKKaz'><pre id='gKKaz'><center id='gKKaz'></center></pre></bdo></b><th id='gKKaz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gKKaz'><tfoot id='gKKaz'></tfoot><dl id='gKKaz'><fieldset id='gKKaz'></fieldset></dl></div>
                          <legend id='gKKaz'><style id='gKKaz'><dir id='gKKaz'><q id='gKKaz'></q></dir></style></legend>
                            <tbody id='gKKaz'></tbody>
                          <tfoot id='gKKaz'></tfoot>
                          主站蜘蛛池模板: 日本精品一区 | 亚洲一区视频在线 | 三级成人片 | 欧美国产视频 | 日韩高清黄色 | 91在线精品秘密一区二区 | 九九在线精品视频 | 成人在线视频网 | 日韩第一页 | 欧美久久久久久久 | 久久国产成人午夜av影院武则天 | 精品国产一区二区三区在线观看 | 欧美午夜在线 | 欧美一区二区网站 | 91av在线免费观看 | 在线观看中文字幕av | 黄色一级视频 | 国产日韩欧美精品一区二区 | 欧美激情在线精品一区二区三区 | 免费成人在线网 | 欧美一级电影免费观看 | 日本三级网站在线观看 | 国产91丝袜在线18 | 狠狠久久 | 久久久一区二区三区 | 久久成人高清视频 | 国产精品自产拍在线观看蜜 | 男女污网站 | 日韩三级在线观看 | 亚洲午夜一区二区 | 日韩精品1区2区 | 一区二区久久电影 | 欧美一区中文字幕 | 国产精品久久久久久中文字 | 蜜桃视频在线观看免费视频网站www | 国产午夜精品一区二区三区四区 | 久久这里只有精品首页 | 精品成人 | 久久精品国产一区二区电影 | 国产精品视频一二三区 | 久久久久久高潮国产精品视 |