M
M
Mussi2014-10-22 16:02:19
Character encoding
Mussi, 2014-10-22 16:02:19

Encoding, everywhere utf-8, in the database - krakozyabry, what should I do?

Server on locale on denver.
There is an interface for adding data to the database in PHP. At the beginning of the php page is the
header('Content-Type: text/html; charset=utf-8');
entire database and table in utf-8

SHOW VARIABLES LIKE  'char%'
character_set_client
utf8
character_set_connection
utf8
character_set_database
utf8
character_set_filesystem
binary
character_set_results
utf8
character_set_server
utf8
character_set_system
utf8
character_sets_dir
\usr\local\mysql-5.5\share\charsets\

in connecting to the database added
mysql_query("set names utf8");
to httpd.conf commented out the line also tried
AddDefaultCharset windows-1251
to change to the
AddDefaultCharset utf-8
data fit into the database in the form of
short code ** error ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
W
whats, 2014-10-22
@whats

change the encoding in the program in which you view data from the database
using the database, look at what encoding the text in the cell is in

D
Dmitry Batulin, 2014-10-22
@DmitryPRG

In my programs I use 2 lines.
Met cases when not enough only one.
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");

P
Pavel Tretyakov, 2014-10-22
@ptretyakov

I remember having this problem too. And everything happened due to the fact that one connected script was not in utf-8 encoding. Check the encodings of your scripts, there may be a problem in the client side, i.e. the data comes already in the wrong encoding.
I also advise you to add htaccess:
AddDefaultCharset UTF-8
I'm paranoid now, I make sure that everything is in utf-8 :-)

M
Mussi, 2014-10-22
@Mussi

In general, as usual, I blunted and corrected the file with the connection in the backup folder, instead of the working one :(
mysql_set_charset('utf8', $conn);
or
mysql_query("SET NAMES 'utf8'");
it was quite enough for the goods to be added to the database in Russian , although the old goods are now displayed as krakozyabry, but it was all test)
thank you all, I apologize for wasting your time :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question