Why you proccess utf8_decode()
the sql query?
Look at http://php.net/manual/en/function.utf8-decode.php for details about utf8_decode()
You have to check a few things.
Whether there is a problem in your database and tables Or in your PHP script.
Database :
CREATE DATABASE test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Table Charset :
CREATE TABLE test.table
(
id INT NOT NULL AUTO_INCREMENT,
text VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = MyISAM;
Connection :
SET NAMES utf8;
E.g :
$mysqli = new mysqli("localhost","my_user","my_password","test_db");
$mysqli->set_charset("utf8");
OR
$link = mysqli_connect("localhost","my_user","my_password","test_db");
mysqli_set_charset($link,"utf8");
Configure the encoding charset of server :
With PHPMyAdmin , Choose UTF-8 when you login.
PHP Script :
header('Content-Type: text/html;charset=UTF-8');
Apache Config (/etc/httpd/conf/httpd.conf) :
AddDefaultCharset UTF-8
Apache .htaccess file :
AddCharset UTF-8 .htm
AddCharset UTF-8 .html
AddCharset UTF-8 .php
PHP Config (/etc/php.ini) :
default_charset = "utf-8"
MySQL Config (/etc/my.cnf ) :
[client]
default-character-set=utf8
[mysqld]
default-collation=utf8_unicode_ci
character-set-server=utf8
default-character-set=utf8
init-connect='SET NAMES utf8'
character-set-client = utf8
User values :
e.g : $_GET
, $_POST
You can use mb_convert_encoding()
for convert your strings to UTF-8.
Useful Links :