go mysql写入特殊字符,如何在MySQL中存储特殊字符-[AîA]

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

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

So far [AîA] turns into [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"

},

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.

解决方案

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

mysql_set_charset()

Final connection code:

$conn = mysql_connect($host, $user, $pass);

mysql_select_db($db, $conn);

mysql_set_charset('utf8',$conn);

Thanks Hakre for answer.

你可能感兴趣的:(go,mysql写入特殊字符)