UTF-8 encoding problem with flash mysql and php
I am programming an on-line game using Flash. I am connecting my flash8 movie with MySQL database through PHP. I am doing very good in that, and I have everything working fine.
The problems come when I am trying to insert (Using the INSERT SQL func) data to the database that are non-english. In other words, UTF-8 data.
I red a lot of articls about that stuff and found and apply the fallowing: 1. In PHP4, you need to tell the PHP to use UTF-8 when using the xml_parser_crater() func, however, in PHP5 that is done automatically. Even though I told PHP5 to use the U开发者_如何学运维TF-8 when calling the func.
Adding the header to the XML sent to PHP from flash.
Force the FLASH to use UTF-8 encoding in the preference options.
Set the encoding in MySQL to UTF-8 (utf8_unicode_ci with InnoDB engine). I can read and insert the other language data correctly in the phpadmin as well.
I did all that in my coding, and still I can't insert such data.
one more strange thing is that, when I use the same link, that the FLASH using, with the XML, that the FLASH creating, on the browser (google chrome), I got the data inserted right in the database!!!!!
I am about to get crazy about that stuff, What am I missing? What causes the problem?
I think you need to ditch the mysql_*
functions and switch to something better like mysqli_*
or PDO. See http://maurus.net/weblog/2006/07/28/typo3-php-mysql-connections-and-unicode/
Right after the call to mysql_connect/mysql_select_db execute this:
mysql_query('set character set utf8');
to tell the PHP-MySQL driver to use UTF-8
Escape your data with mysql_real_escape_string()
精彩评论