gdfhghjdfghgfhf 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted October 15, 2012 Share Posted October 15, 2012 (edited) 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. Edited October 15, 2012 by requinix Quote Link to comment Share on other sites More sharing options...
gdfhghjdfghgfhf Posted October 15, 2012 Author 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() Quote Link to comment 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. Quote Link to comment 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.