marchost Posted June 11, 2009 Share Posted June 11, 2009 Hi, i'm having a weird problem with UTF-8 accent. Basically, I have a form that saves post data to a mysql database. Let say I type in 'André', eveything is displayed correctly on the page but it get saved as André in the database. My only concern is in the database, on the user side eveything is normal. If I go directly in phpmyadmin and manually replace 'André' with 'André' it still display info correctly on the page. Forums are really my last resort, I looked for an answer for hours. I have tried the following but I get the same result: -httpd.conf- AddCharset UTF-8 .utf8 AddDefaultCharset UTF-8 -php.ini- default_charset = "utf-8" -my.cnf- character-set-server=utf8 default-collation=utf8_unicode_ci But if I do mysql_query("SET NAMES 'utf8'"), the data is displayed as André on the user side and in the database. Also, if I echo posted data it is displayed as 'André' or if I echo the query on the page, I get again 'André' Basically, my problem seems to be between php and mysql... Thanks in advance for any answers Marc http://www.ipinfodb.com/ Link to comment https://forums.phpfreaks.com/topic/161860-utf8-encoding-accent-headache/ Share on other sites More sharing options...
marchost Posted June 11, 2009 Author Share Posted June 11, 2009 I forget to say that eveything is UTF-8 : database as utf8_general_ci And in the header : <meta http-equiv="content-type" content="text/html; charset=UTF-8"> Link to comment https://forums.phpfreaks.com/topic/161860-utf8-encoding-accent-headache/#findComment-853978 Share on other sites More sharing options...
ted_chou12 Posted June 11, 2009 Share Posted June 11, 2009 have you tried the function htmlentities()? Ted Link to comment https://forums.phpfreaks.com/topic/161860-utf8-encoding-accent-headache/#findComment-854059 Share on other sites More sharing options...
marchost Posted June 11, 2009 Author Share Posted June 11, 2009 Hi ted, im not sure I see how I could use htmlentities to solve my problem... Link to comment https://forums.phpfreaks.com/topic/161860-utf8-encoding-accent-headache/#findComment-854090 Share on other sites More sharing options...
ted_chou12 Posted June 11, 2009 Share Posted June 11, 2009 sorry, i meant iconv() $text = "André"; echo iconv("UTF-8", "ISO-8859-1", $text); UTF-8|ASCII Unicode Big5|Traditional Chinese GB2312|Simplified Chinese EUC-JP|Japanese EUC-KR|Korean KOI8-R|Russian ISO-8859-1|Latin 1(West European) ISO-8859-2|Latin 2(East European) ISO-8859-3|Latin 3(South European) ISO-8859-4|Latin 4(North European) ISO-8859-5|Cyrillic ISO-8859-6|Arabic ISO-8859-7|Greek ISO-8859-8|Hebrew ISO-8859-9|Turkish ISO-8859-10|Nordic ISO-8859-15|Latin 1(French, Finnish) windows-874|Thai i'm not very familiar with all the charsets, u probably have to explore the list to get the right one or let an expert point u in the right direction. The link is here: http://us2.php.net/manual/en/function.iconv.php I am pretty sure iconv() is the right function to use though Ted Link to comment https://forums.phpfreaks.com/topic/161860-utf8-encoding-accent-headache/#findComment-854135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.