Home > php_mysql > UTF-8 and apache – mysql – php

UTF-8 and apache – mysql – php

December 16th, 2009 karlosp Leave a comment Go to comments

Settings a LAMP server to work in full unicode UTF-8 :

httpd.conf:

CODE:
  1. AddCharset UTF-8 .utf8
  2. AddDefaultCharset UTF-8

php.ini

CODE:
  1. default_charset = "utf-8"

my.cnf

CODE:
  1. character-set-server=utf8 default-collation=utf8_unicode_ci

In all your PHP scripts :

CODE:
  1. mysql_query("SET NAMES 'utf8';",$con);

Importing database :

CODE:
  1. 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 :

CODE:
  1. <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;/>

Categories: php_mysql Tags:
  1. No comments yet.
  1. No trackbacks yet.
94310 pages viewed, 370 today
49928 visits, 74 today
FireStats icon Powered by FireStats