Today, I setup a mysql database with collation : utf8_general_ci. I input Chinese character from web page with meta tag : charset=utf-8". When I retrieved these records, they were shown as "???". After studying, I found that I need the following line :
mysql_query('SET character_set_results=utf8');
before
$result = mysql_query($query);
I hope this information is useful for those who are developing web page with Chinese characters records in mysql.
Thursday, August 1, 2013
php Special Character Escape Sequences
useful examples
==================
mysql>SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';+-------+---------+-----------+--------+--------+ | hello | "hello" | ""hello"" | hel'lo | 'hello | +-------+---------+-----------+--------+--------+ mysql>SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello";+-------+---------+-----------+--------+--------+ | hello | 'hello' | ''hello'' | hel"lo | "hello | +-------+---------+-----------+--------+--------+ mysql>SELECT 'This\nIs\nFour\nLines';+--------------------+ | This Is Four Lines | +--------------------+ mysql>SELECT 'disappearing\ backslash';+------------------------+ | disappearing backslash | +------------------------+
Subscribe to:
Comments (Atom)