After sending from the form of the text in Russian, the text is written into the base like this: How can I fix this? What encoding should be in the script and in the database?

  • in the database utf-8 =) - Gorets

3 answers 3

mysql_query ("SET CHARACTER SET 'utf8'", $db); 

So put will work.

  • $ db means a variable storing mysql_connect () - mixail
  • Now it puts questions into the database and displays them! I use it in the execution script and on the page where it should be displayed) - Zine
  • you write mysql_connect - mixail in the beginning

What encoding should be in the script and in the database?

The same, for example in the windows-1251 script -> in the database cp-1251-general-ci

  • A connection encoding what affects? :-) - Angelina_Jo
  • Here, from a practical point of view, it is simpler; unnecessary functions of an encoding envelope are unnecessary if the data from the script and the base are in one encoding. - Alexis

If PHP 5 || >, and MySQL 5.0.7 || > it is better to use the function:

  mysql_set_charset(); 

If not, then after connecting to the database, make a request:

 mysql_query("SET NAMES utf8"); 
  • It does not help! When registering, normal Russian letters are entered into the database as well. What could be the problem? - Zine
  • The script itself is stored in the same encoding used in other places? - Angelina_Jo
  • @Angelina_Jo how to define or save to yutf8?) - Zine
  • In the editor (yes, even in notepad there is a choice of encoding when saving the file). :-) By the way, what's your code? - Angelina_Jo