如何在MySQL中插入西班牙语字符? [英] How to insert Spanish characters in MySQL?
问题描述
我试图用西班牙字符做一个简单的插入,没有成功。这是我简单的MySQL表结构:
CREATE TABLE学生(
ID INTEGER NOT NULL AUTO_INCREMENT,
名VARCHAR(100)NOT NULL,
姓氏VARCHAR(100)NOT NULL,
约束PK_STUDENT PRIMARY KEY(ID)
)CHARACTER SET UTF8 COLLATE utf8_general_ci;
名称
和 lastname
字段将来自西班牙人,他们的名字和名字如下所示:
-
丹尼尔·贝拉斯克斯
-
哈维尔·楠斯
-
维克托·桑切斯
但是当我执行以下操作时:
MySQL的> INSERT INTO学生(姓名,姓氏)VALUES('Víctor','Sanchez');
我收到此错误:
错误1366(HY000):字符串值不正确:行
的列'name'的'\xA1ctor'$ 1
嗯,在互联网上进行搜索时,我对排序规则,文字和所有相关内容感到困惑。
这是正确的方法呢?只要知道我使用PHP,我知道一种检索一些特殊字符的方法是使用 htmlentities($ value);
提前感谢
请看这个
'p>它会帮助你。
这是关于编码字符编码
I am trying to do a simple insert with Spanish characters without success. This is my simple MySQL table structure:
CREATE TABLE student (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
lastname VARCHAR(100) NOT NULL,
CONSTRAINT PK_STUDENT PRIMARY KEY (id)
) CHARACTER SET utf8 COLLATE utf8_general_ci;
The name
and lastname
fields will be from Spanish people, their first and last names are like this:
Daniel Velásquez
Javier Ñañez
Víctor Sánchez
But when I do the following:
mysql> INSERT INTO student (name, lastname) VALUES ('Víctor', 'Sanchez');
I get this error:
ERROR 1366 (HY000): Incorrect string value: '\xA1ctor' for column 'name' at row
1
Well, I am really confused about collations, encondings and everything related when doing a search on internet.
So, what is the correct way to deal with this? Just to know I am using PHP and I know that a way to retrieve some special characters is using htmlentities($value);
Thanks in advance.
please take a look at this
it will help you
Handling Unicode Front To Back In A Web App
this is about the encoding character encoding
这篇关于如何在MySQL中插入西班牙语字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!