can't insert russian text into mysql database

前端 未结 5 2308
青春惊慌失措
青春惊慌失措 2020-12-03 06:29

When I\'m trying to insert russian text into MySQL database it inserts it like: г???????????? ?? ????????
Рісѓрїр°ріс‹рї р° с‹рір°рї

So, I have two pages: regist

相关标签:
5条回答
  • 2020-12-03 06:41

    Check your MySQL configuration and ensure that your encoding is defined correctly. Add these lines to my.cnf or my.ini, which ever your installation uses. These settings did the trick for me:

    [client]
    default-character-set=utf8
    


    [mysql]
    default-character-set=utf8
    


    [mysqld]
    character-set-server=utf8
    
    0 讨论(0)
  • 2020-12-03 06:50

    I store greek in tables created like ths:

    CREATE TABLE `test` (
      `test_id` SMALLINT UNSIGNED NOT NULL   AUTO_INCREMENT,
      `test_name` VARCHAR(30)  NOT NULL,
      PRIMARY KEY  (`test_id`)
     ) ENGINE=InnoDB   DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
    

    Or if table already created I guess you can change the charset it in the phpmyadmin interface. Maybe this helps.

    0 讨论(0)
  • 2020-12-03 06:51

    I have tried multiple collations in phpMyAdmin as well as changing the charset of the page, which didn;t make sense but i was willing to try anything after two days of research. this command helped me: mysql_set_charset('utf8');

    Collation on the column was set to koi8r_general_ci

    0 讨论(0)
  • 2020-12-03 07:01

    Edit your structure field to set collation utf16_general_ci.
    After that insert your data.

    0 讨论(0)
  • 2020-12-03 07:02

    Try calling mysql_set_charset('utf8'); after connecting to the database. I think it's similar to executing a SET NAMES query, but since the PHP manual says using that function over a SET NAMES query is recommended, I'd try it.

    Also, when you display your content, you could try echo htmlentities($string, ENT_COMPAT, 'UTF-8');

    0 讨论(0)
提交回复
热议问题