pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  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="bypbuty" 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="lnwd38b" 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="ybngdmq" 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>
                          主站蜘蛛池模板: 大_小鼠elisa试剂盒-植物_人Elisa试剂盒-PCR荧光定量试剂盒-上海一研生物科技有限公司 | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 湖南自考_湖南自学考试| 机房监控|动环监控|动力环境监控系统方案产品定制厂家 - 迈世OMARA | 桂林腻子粉_内墙外墙抗裂砂浆腻子粉推荐广西鑫达涂料厂家供应 | 工业用品一站式采购平台|南创工品汇-官网|广州南创 | TPE_TPE热塑性弹性体_TPE原料价格_TPE材料厂家-惠州市中塑王塑胶制品公司- 中塑王塑胶制品有限公司 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 艾默生变频器,艾默生ct,变频器,ct驱动器,广州艾默生变频器,供水专用变频器,风机变频器,电梯变频器,艾默生变频器代理-广州市盟雄贸易有限公司官方网站-艾默生变频器应用解决方案服务商 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 济南网站建设_济南网站制作_济南网站设计_济南网站建设公司_富库网络旗下模易宝_模板建站 | 双舌接地线-PC68数字式高阻计-ZC36|苏海百科 | 广州办公室设计,办公室装修,写字楼设计,办公室装修公司_德科 | 北京网站建设|北京网站开发|北京网站设计|高端做网站公司 | 干洗加盟网-洗衣店品牌排行-干洗设备价格-干洗连锁加盟指南 | 首页_欧瑞传动官方网站--主营变频器、伺服系统、新能源、软起动器、PLC、HMI | 银川美容培训-美睫美甲培训-彩妆纹绣培训-新娘化妆-学化妆-宁夏倍莱妮职业技能培训学校有限公司 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 杭州门窗厂家_阳光房_包阳台安装电话-杭州窗猫铝合金门窗 | 北京翻译公司-专业合同翻译-医学标书翻译收费标准-慕迪灵 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 动库网动库商城-体育用品专卖店:羽毛球,乒乓球拍,网球,户外装备,运动鞋,运动包,运动服饰专卖店-正品运动品网上商城动库商城网 - 动库商城 | 喷播机厂家_二手喷播机租赁_水泥浆洒布机-河南青山绿水机电设备有限公司 | 一体化污水处理设备_生活污水处理设备_全自动加药装置厂家-明基环保 | 冰雕-冰雪世界-大型冰雕展制作公司-赛北冰雕官网 | 代理记账_免费注册公司_营业执照代办_资质代办-【乐财汇】 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | MVE振动电机_MVE震动电机_MVE卧式振打电机-河南新乡德诚生产厂家 | 「安徽双凯」自动售货机-无人售货机-成人用品-自动饮料食品零食售货机 | 真石漆,山东真石漆,真石漆厂家,真石漆价格-山东新佳涂料有限公司 | 杭州代理记账费用-公司注销需要多久-公司变更监事_杭州福道财务管理咨询有限公司 | 陕西华春网络科技股份有限公司 | 钢木实验台-全钢实验台-化验室通风柜-实验室装修厂家-杭州博扬实验设备 | 澳洁干洗店加盟-洗衣店干洗连锁「澳洁干洗免费一对一贴心服务」 干洗加盟网-洗衣店品牌排行-干洗设备价格-干洗连锁加盟指南 | 高中学习网-高考生信息学习必备平台 | 小型UV打印机-UV平板打印机-大型uv打印机-UV打印机源头厂家 |松普集团 | 温室大棚建设|水肥一体化|物联网系统 | 防潮防水通风密闭门源头实力厂家 - 北京酷思帝克门窗 | 捷码低代码平台 - 3D数字孪生_大数据可视化开发平台「免费体验」 |