MySql西班牙语字符数据 [英] MySql spanish character data

查看:886
本文介绍了MySql西班牙语字符数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含西班牙字符的数据库。填充数据库我从客户端页面的字符编码= UTF-8获取值。当我在mySql数据库中插入值时,行包含更改的数据。例如,如果我插入'México',数据库中的条目是'México'。这个影响是当我做一个查询指定'México'的表,我没有结果。我的问题是如何在mysql数据库插入西班牙语或其他拉丁口音?我hav尝试所有的排序,htmlentities()等,但没有什么工作!
当进行mysql查询时,我检查了什么数据被发送,它是正确的形式'México',但是当我通过phpmyadmin看到表项,它的改变!!

i hav a database that contains spanish characters. to populate the database i am getting the values from client page which has character encoding=UTF-8. when i insert the values in mySql database the rows contain altered data. for example if i insert 'México', the entry in the database is 'México'. the impact this has is when i do a query on the table specifying 'México', i get no results. my question is how do u insert spanish or other latin accent in mysql database? i hav tried all the collations, htmlentities() etc but nothing works!! when making mysql query i checked what data is being sent and it is in its correct form 'México' but when i see the table entry through phpmyadmin, its altered!!

推荐答案

将您的mysql数据库/表/列编码更改为UTF-8(并将排序规则设置为兼容值)。

Change your mysql database/ table / column encoding to UTF-8 (and also set the collation to a compatible value).

ALTER TABLE mytable CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE mytable 
MODIFY country CHAR(50) 
CHARACTER SET utf8 COLLATE utf8_general_ci;

在连接时还要指定PHP端的字符集。

Also specify the char set at the PHP side when connecting.

mysql_set_charset('utf8',$conn); 

请参阅本文了解更多信息和脚本批量更改数据库中的每个表/列。

Take a look at this article for further info and a script to batch change every table / column in a database.

这篇关于MySql西班牙语字符数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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