keenlearner Posted January 26, 2007 Share Posted January 26, 2007 My site is 90% english, however there are some pages that i need to display in chinese character. In fact, arabic, russia, spanish. In mysql, i try to use collation utf8_general_ci . So when i input the data using phpmyadmin, i type chinese character e.g 福(lucky) into the record, save it. Unfortunately when i use php to get the data from mysql database and present it on the web, it appear as '?' (question mark). How do i show it on the web correctly ? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/ Share on other sites More sharing options...
effigy Posted January 26, 2007 Share Posted January 26, 2007 What charset are you using in your meta tag? [url=http://www.w3.org/TR/html4/charset.html]More information.[/url] Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-169892 Share on other sites More sharing options...
keenlearner Posted January 26, 2007 Author Share Posted January 26, 2007 Thank's for the reply. it's utf-8. Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-169896 Share on other sites More sharing options...
effigy Posted January 26, 2007 Share Posted January 26, 2007 Are you sure the database is storing it correctly? What does[tt] SELECT HEX(field) from TABLE [/tt]give you for the character? Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-169904 Share on other sites More sharing options...
keenlearner Posted January 26, 2007 Author Share Posted January 26, 2007 I never come acroos with HEX(), however when i try that in mysql command line client, it shows E4B8BD for 丽 character, does it mean the database does not store correctly ? When i see in phpmyadmin the character shown as 丽. Is there a special command to be used when connecting to the database ? Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-169915 Share on other sites More sharing options...
effigy Posted January 26, 2007 Share Posted January 26, 2007 Hmmm.... It sounds like things are working properly. Was your table assigned a character set initially? You can check via[tt] SHOW CREATE TABLE [i]table_name[/i][/tt]. Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-169998 Share on other sites More sharing options...
keenlearner Posted January 26, 2007 Author Share Posted January 26, 2007 Thank you so much, My problem solved, we should add this code before querying for data[code]mysql_query("SET CHARACTER SET utf8", $connection); mysql_query("SET NAMES utf8", $connection); [/code] ;D Quote Link to comment https://forums.phpfreaks.com/topic/35833-solved-store-chinse-character-in-mysql/#findComment-170003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.