MySql spanish character data

前端 未结 3 1192
一整个雨季
一整个雨季 2021-01-14 05:19

i hav a database that contains spanish characters. to populate the database i am getting the values from client page which has character encoding=UTF-8. when i insert the va

3条回答
  •  盖世英雄少女心
    2021-01-14 06:05

    Change your mysql database/ table / column encoding to UTF-8 (and also set the collation to a compatible value).

    ALTER TABLE mytable CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
    ALTER TABLE mytable 
    MODIFY country CHAR(50) 
    CHARACTER SET utf8 COLLATE utf8_general_ci;
    

    Also specify the char set at the PHP side when connecting.

    mysql_set_charset('utf8',$conn); 
    

    Take a look at this article for further info and a script to batch change every table / column in a database.

提交回复
热议问题