Unknown user @38.107.191.102

Get Utf-8 with Apache, MySQL and PHP

HTML code

For local saves without server.

 
 <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>

PHP code

 <?php
 header('Content-type: text/html; charset=UTF-8'); 
 // ...
 ?>

Apache/.htaccess code

If you don't have specified the charset encoding with PHP, you can do it through apache with the .htaccess file.

 
 AddDefaultCharset UTF-8

MySQL code

At database creation

 CREATE DATABASE table_name
 CHARACTER SET utf8
 COLLATE utf8_bin;

At table creation

 CREATE TABLE tutu (
 my_field VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
 ...
 ) CHARACTER SET utf8; 

PHP + MySQL access

After the database connection and selection, execute the following query

 <?php
 mysql_query("SET NAMES 'utf8'");
 // ...
 ?>

Initial author: olivier Last modification date: February the 3rd, 2009 by olivier.