UTF-8 and apache – mysql – php
Settings a LAMP server to work in full unicode UTF-8 :
httpd.conf:
AddCharset UTF-8 .utf8 AddDefaultCharset UTF-8
php.ini
default_charset = "utf-8"
my.cnf
character-set-server=utf8 default-collation=utf8_unicode_ci
In all your PHP scripts :
mysql_query("SET NAMES 'utf8';",$con);
Importing database :
mysql -h host -u username -p password --default_character_set utf8 database < file.sql
Dont forget to add UTF-8 in the head of all your HTML files :
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
Categories: php_mysql