Characters such as à are not displayed correctly from MySQL

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

So, on one computer, it shows this name:

SAUL FRANCISCO GARCÃA RODRÃGUEZ

Database mapping latin1_swedish_ci, and table sorting utf8_general_ci.

On another computer, it looks like this (I want it to be like this):

SAUL FRANCISCO GARCÍA RODRÍGUEZ

Names are obtained in the tag <select>. The language of the two browsers is English, and the Html file is the same in both environments, so I think it has to do with the encoding or encoding for the php.ini file

I tried to change the values ​​in php.ini, but nothing changed, and I can not find the answer anywhere.

The only difference is that when the results are displayed as I want, I installed WAMP, and on the other computer I installed Apache, MySQL and PHP separately.

Sorry if the details are not very informative, but I do not know where I am going wrong.

PS In both databases, the data looks as follows from the MySQL console:

SAUL FRANCISCO GARCÃA RODRÃGUEZ
+2
source share
3 answers

Editing php.iniwill not help you in this case.

What is database data sorting that gives you a problem? By default, most MySQL installs latin1_swedish_ciinstead utf8_general_cifor newly created databases.

Change the database configuration and try again.

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

, :

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

:

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

, , , reimport :

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

MySQL , , my.cnf. 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
+7

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> html

+2

PHP UTF-8:

header('Content-Type: text/html; charset=utf-8');

HTML , UTF-8, HEAD :

<meta charset="UTF-8">

+2

Source: https://habr.com/ru/post/1540059/


All Articles