人物就像一个没有从MySQL正确显示 [英] Characters like à not displaying correctly from MySQL

查看:179
本文介绍了人物就像一个没有从MySQL正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在两台计算机在HTML文件中显示来自数据库的结果时,我有一个问题。

所以,在一台电脑它显示了一个名字是这样的:

  SAUL FRANCISCOGARCÃARODRÃGUEZ

该数据库的排序规则是 latin1_swedish_ci 和表的排序规则是 utf8_general_ci

在另一台电脑上就显示了这样的(我想它是这样):

  SAUL弗朗西斯科 - 加西亚RODRÍGUEZ

该名都列出一个<选择> 标记中的两款浏览器的语言为英语和HTML文件在两个环境中相同的,所以我认为它有做的字符集或编码php.ini文件

我曾尝试在的php.ini 但没有任何变化而变化的值,我不能在任何地方找到答案。

唯一的区别是,如果结果得到显示,因为我想我安装WAMP和其他计算机我安装了Apache,MySQL和PHP分开。

很抱歉,如果细节不是非常丰富,但我不知道我要去哪里错了。

P.S。在这两个数据库中的数据看起来像这样从MySQL控制台:

  SAUL FRANCISCOGARCÃARODRÃGUEZ


解决方案

修改的php.ini 不会帮助你很多在这样的情况下。

什么是数据库给你一个问题的数据整理?默认情况下,大多数MySQL安装为新创建的数据库设置的 latin1_swedish_ci 而不是 utf8_general_ci

更改数据库和放大器的整理;再试一次。

  ALTER DATABASE CHARACTER SET UTF8 [数据库名称];

如果这是一个特定的表,排序规则是可以改变像这样:

  ALTER TABLE [你的表的名称]转换为CHARACTER SET UTF8;

和如果它是表中的一个特定的列

  ALTER TABLE [你的表的名称]修改[您列的名称] [其他设置] CHARACTER SET UTF8 COLLATE utf8_general_ci;

或许你可以导出当前的数据库,创建一个与此命令和放大器一个新的数据库;重新导入数据:

  CREATE DATABASE CHARACTER SET UTF8 COLLATE utf8_general_ci [数据库名称];

如果你想对MySQL的一个永久性改变安装机器给你一个问题上,去和编辑的my.cnf 。下面将设置全产业链为UTF-8:

  [客户]
默认字符集= UTF8[MySQL的]
默认字符集= UTF8[mysqld的]
整理服务器= utf8_uni code_ci
初始化连接='SET NAMES UTF8
字符集服务器= UTF8

I have a problem when displaying results from a database in an HTML file in two computers.

So, in one computer it shows a name like this:

SAUL FRANCISCO GARCÃA RODRÃGUEZ

The collation of the database is latin1_swedish_ci and the collation of the tables is utf8_general_ci.

In the other computer it shows like this (I want it to be this way):

SAUL FRANCISCO GARCÍA RODRÍGUEZ

The names get listed in a <select> tag The language of the two browsers is English and the Html file is the same on both environments so I think It has to do with the charset or encoding for the php.ini file

I have tried changing the values in php.ini but nothing changes and I can't find the answer anywhere.

The only difference is that where the results get displayed as I want I installed WAMP and in the other computer I installed Apache, MySQL and PHP separately.

Sorry if the details are not very informative but I have no clue where I'm going wrong.

P.S. On both databases the data looks like this from the MySQL console:

SAUL FRANCISCO GARCÃA RODRÃGUEZ

解决方案

Editing php.ini won’t help you much in a case like this.

What is the data collation of the database giving you an issue? By default, most MySQL installs set latin1_swedish_ci instead of utf8_general_ci for newly created databases.

Change the collation of the database & try again.

ALTER DATABASE [name of your database] CHARACTER SET utf8;

If this is a specific table, the collation can be changed as so:

ALTER TABLE [name of your table] CONVERT TO CHARACTER SET utf8;

And if it is a specific column in a table:

ALTER TABLE [name of your table] MODIFY [name of your column] [other settings] CHARACTER SET utf8 COLLATE utf8_general_ci;

Or perhaps you could export the current database, create a new database with this command & reimport the data:

CREATE DATABASE [name of your database] CHARACTER SET utf8 COLLATE utf8_general_ci;

And if you want to make a permanent change to the MySQL install on the machine giving you an issue, go and edit my.cnf. The following would set the whole chain to UTF-8:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

这篇关于人物就像一个没有从MySQL正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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