I
I
Ilya Pavlov2014-10-29 18:08:26
PHP
Ilya Pavlov, 2014-10-29 18:08:26

Curve saving of characters in MySql via PHP. What to do?

Table (utf8_general_ci).
PHP file making mysql_query() query in utf-8 without bom.
The data to this file is sent from the index.html form, which is also in utf-8

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
asd111, 2014-10-29
@asd111

look towards SET character_set_client, SET character_set_connection SET character_set_result also see set names and collation
habrahabr.ru/post/10983

T
T4-100, 2014-10-29
@isawillbenice

Had this problem helped
mysql_set_charset('utf8', $db);

F
FanatPHP, 2014-10-30
@FanatPHP

Most likely, the reason is the epidemic disease of modern shkoloty: a fatal inability to trace cause-and-effect relationships. For example, if when viewing the data output from the database, they are displayed incorrectly, then it is concluded that they were recorded incorrectly. Or, as an option - the author himself makes some profound gestures in the code, not understanding their meaning - simply because the guys suggested the same way, and he stupidly copied - and they just spoil the data.
But in any case, the problem is in the inability to divide the process into stages, and control the data at each. In order to subsequently at least ask an adequate question, such as "When data is transferred from the browser, the data is corrupted." Or "when writing to the database, the data is corrupted." Instead, we get a helpless "Something is happening with the data, but what exactly and at what moment - I don't know."

I
Ilya Pavlov, 2014-10-30
@PiCoderman

He asked, he answered.
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARSET SET 'utf8'");
mysql_query("SET SESSION collation_connection = 'utf8_general_ci'");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question