Guest Posted October 15, 2012 Share Posted October 15, 2012 I'm trying to add text into a mysql field containing french accents "é" will end up as "é" How can i fix that ? My sql field is already set to utf8 and i'm running utf8_encode() on the value i'm adding to SQL... what's wrong ? Thanks Link to comment https://forums.phpfreaks.com/topic/269478-problem-with-accents-in-mysql/ Share on other sites More sharing options...
requinix Posted October 15, 2012 Share Posted October 15, 2012 You're not outputting UTF-8. Well, technically yes you are, but whatever's displaying the characters doesn't think they're UTF-8. For PHP send another header: header("Content-Type: text/html; charset=utf-8"); (or any other text/* type) For HTML: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> (same as the header above) For XML: <?xml version="1.0" encoding="utf-8" ?> Though it could be you're doubly-encoding the stuff. Remove the call to utf8_encode() and see if that fixes it. But the above changes are still important so make sure something like them is in place. Link to comment https://forums.phpfreaks.com/topic/269478-problem-with-accents-in-mysql/#findComment-1385267 Share on other sites More sharing options...
Guest Posted October 15, 2012 Share Posted October 15, 2012 Well when i look in phpmyadmin the accents aren't correctly displayed "é" are displayed as "é" in the database so i don't think the problem is about output... I also have other strings with accents on the same page and they are correctly displayed. I only have a problem with accents coming from SQL. I also tryed without utf8_encode() Link to comment https://forums.phpfreaks.com/topic/269478-problem-with-accents-in-mysql/#findComment-1385274 Share on other sites More sharing options...
requinix Posted October 15, 2012 Share Posted October 15, 2012 What encoding are your databases/tables in? Those need to be UTF-8 too. You may need to send a SET NAMES utf8 when you first open your database connection too. Link to comment https://forums.phpfreaks.com/topic/269478-problem-with-accents-in-mysql/#findComment-1385399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.