tmyonline Posted September 11, 2009 Share Posted September 11, 2009 Guys, I'm not exactly sure whether this problem can be resolved using PHP or MySQL but here it is: The content of my site is in Vietnamese. I need to store the Vietnamese data in MySQL, so in MySQL, I set the Collation to utf8_general_ci and the Vietnamese language appears fine. However, when I perform database query and display these data on the browser, they appear corrupted. In my HTML DOCTYPE declaration, I set "charset=utf-8". Any ideas ? Thanks. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/ Share on other sites More sharing options...
mikesta707 Posted September 11, 2009 Share Posted September 11, 2009 I think you are supposed to set the charset in a meta tag, not the doctype declaration, like so <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> but I could be wrong. just did a google search and this line of code came up in one of the pages Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916822 Share on other sites More sharing options...
tmyonline Posted September 11, 2009 Author Share Posted September 11, 2009 Yes, that's what I meant by DOCTYPE declaration, that whole chunk including the meta tag. I guess I needed to be more specific but I did have it in the correct (default) place. Thanks. I hope to hear from many of you. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916827 Share on other sites More sharing options...
mikesta707 Posted September 11, 2009 Share Posted September 11, 2009 hmm maybe post code, I dont have much experience with showing other languages on websites though Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916829 Share on other sites More sharing options...
thebadbad Posted September 11, 2009 Share Posted September 11, 2009 You also need to set NAMES and CHARACTER SET to UTF-8. Run these queries just after you've connected to your database: mysql_query("SET NAMES 'utf8'", $connection); mysql_query("SET CHARACTER SET 'utf8'", $connection); Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916845 Share on other sites More sharing options...
tmyonline Posted September 11, 2009 Author Share Posted September 11, 2009 Nope, it's not working ! Come on guys Hope to hear more from you guys. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916902 Share on other sites More sharing options...
thebadbad Posted September 11, 2009 Share Posted September 11, 2009 Did you store the MySQL link identifier returned by mysql_connect() in $connection prior to running the queries? A last thing to try could be to set the header: header('Content-type: text/html; charset=utf-8'); If it still doesn't work, I don't know what to tell you. It should work if you do the things right that you and I have outlined. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-916908 Share on other sites More sharing options...
tmyonline Posted September 12, 2009 Author Share Posted September 12, 2009 Thanks thebadbad, it worked. But, now I'm having another related problem. I have written some PHP code to handle document upload. Because the document file names are in Vietnamese, after the uploading process is complete, the font in the filenames got corrupted. I have used PHP "echo" command to track the errors. What I found is that: // filename appeared fine here - just before the move_uploaded_file() gets executed move_uploaded_file($_FILES['doc_' . $i]['tmp_name'], $uploadPath); Once the move_uploaded_file() got executed, I checked the document in the uploaded folder, it did get uploaded but, now, its filename got corrupted. Any ideas ? Thanks. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-917217 Share on other sites More sharing options...
thebadbad Posted September 14, 2009 Share Posted September 14, 2009 I'm afraid move_uploaded_file() and similar functions don't support Unicode filenames. Link to comment https://forums.phpfreaks.com/topic/173921-solved-problem-with-font-display-charset/#findComment-918208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.