Broken encoding when adding data in Russian to MySQL

When you fill out the database in Russian through the form, question marks are added to the database. Here is a picture of the form -

alt text

Here is a picture of the result of adding -

alt text

Tell me how to solve this.

Author: alex-rudenkiy, 2013-02-20

1 answers

After connecting to the database, send requests to

$db->query('set names utf8');
$db->query("set lc_time_names='ru_RU'");

This will set UTF-8 for the current connection to mysql and allow you to get the names of months, days of the week, etc. in Russian, for example.

For the browser, send headers via header and set the meta tag. Plus, the script itself must of course be in UTF-8


After that, it is easier to delete the existing database entries with the wrong encoding, since they will most likely return the wrong result

 1
Author: Gedweb, 2013-02-20 18:29:23