如何在MySQL中存储特殊字符-[AîA] [英] How to store special charaters in MySQL - [AîA]

查看:445
本文介绍了如何在MySQL中存储特殊字符-[AîA]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将其存储在MySQL中

I am wondering how I would go about storing this in MySQL

我通过将其从油膏脚本发布到php并将其插入到MySQL数据库中来进行存储.

I am storing it by posting it from a greasemonkey script to php to insert it into a MySQL database.

到目前为止,[AîA]变成了[AîA]

这是我发布功能的一部分:

this is part of my post function:

GM_xmlhttpRequest({
    method: "POST",
    url: URL + "Script/player.php",
    data: LoginUrl,

    headers: {
        "User-Agent":"Update Script",
        "Content-Type": "application/x-www-form-urlencoded"
    },

我认为我可能也需要更改Content类型,但我尝试将其破坏为UTF-8.我也尝试使用:

I think I might need to change the Content type too UTF-8 but when I tried this it broke the script. I also tried using:

encodeURIComponent(Name)

但是,此操作无法正常运行,或者由于未正确设置标头而被破坏.

But this didn't work properly or was broken because of not setting header properly.

推荐答案

在将信息提交到数据库的PHP文件中,我必须使用

In the PHP file that submits the information into the database I had to set the charset using

mysql_set_charset()

最终连接代码:

$conn = mysql_connect($host, $user, $pass);
mysql_select_db($db, $conn);
mysql_set_charset('utf8',$conn);

感谢哈克雷的回答.

这篇关于如何在MySQL中存储特殊字符-[AîA]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆