dsnnvpobaljihv3490 2013-10-07 09:20
浏览 40
已采纳

如何自动将文本字段输入保存为utf8编码数据?

How to save text field input into mytable as utf8 encoded data, since textarea input automatically changing into utf8 encoded data,

  • 写回答

2条回答 默认 最新

  • dongxian0320 2013-10-07 09:27
    关注

    Firstly, make sure that your database table is set to character set UTF-8.

    Secondly, set the page your are submitting data from as UTF-8 with the following meta tag:

    <head>
    <meta charset="UTF-8">
    </head>
    

    Then when making your connection to the database you can execute the following query to set any subsequent queries to the UTF-8 character set too:

    query("SET NAMES utf8"); 
    

    See: SET NAMES utf8 in MySQL? and http://www.w3schools.com/tags/att_meta_charset.asp

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?