Hi All,

I'm working on a form that should allow the user to insert a brief description of a picture. The user is allowed to write text in several languages so i need to be able to store (in a db) and then display accented letters like è, ü etc.

Problem is that when I try to display them, characters appear in a different way (eg, like a capital "A" with a tilde on top etc.)

the code performs the following operations on the text inserted in the form:

$title = htmlentities($_POST['title']);
if (!get_magic_quotes_gpc()) {
    $title = mysql_real_escape_string($title);
}
// ...then it saves it to DB

What I get is that a text like "è ü à" becomes "è ü à" which don't think is correct and doesn't display correctly when i try to pront it, even using html_entity_decode.
What am I doing wrong?

I've tried inverting the two instructions (ie mysql_real_escape_string before htmlentitites) but didn't work.

thanks,
Patrick

    is your content header defined in the output page?

    ie; header('Content-Type: text/html; charset="UTF-8"'); or whatever the html <meta> one is

      yes it is now and it works. 🙂

      i still don't understand though why the letters appear wrong in the sql database

      eg.

      1. i write a description that contains accented characters, eg "èàù".
      2. I save the description in MySQL db. if i look at it using PhpMyAdmin, the description looks like "èà ù"
      3. when i query the data and put them on a web page, they apper correctly (èàù)
        so, in the end it works but i have to say I'm still confused about this thing...
        i've checked and both my page and phpmyadmin page have the header set in the same way,
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        😕

        is the db Collation set to one of the utf8 options?

          Write a Reply...