When I insert é to mysql, it becomes é

Whenever I am adding accented characters to my mysql table, my special characters are getting displayed like that in the database.

Everything is in utf8. Any idea please ?

PS:

  1. My MySQL connection page starts with header(“Content-Type: text/html; charset=UTF-8”);
  2. Just below my mysql_connect, I have mysql_set_charset(‘utf8’, $conn);
  3. At the top of every page (top.php), I have ini_set(‘default_charset’, ‘utf-8’)
  4. My MySQL table has the collation utf8_unicode_ci
  5. My page properties in DW are: UTF-8, Unicode normalisation form: C, BOM is checked.

Thus, if I send bébé ç through a php form, I get bébé ç in the database and the same gets echoed if I print the value as text. However, if I echo the value as form-field-value I get bébé ç as initially sent.

On the other hand, if I edit the table directly (via phpmyadmin) and write bébé ç in place of bébé ç, I get bébé ç echoed when I print that as text, and the form-field-value reads b�b� �.

So, this is another question, when what we print in form value is different from what we print as text value :slight_smile:

Thanks for any help :slight_smile:

Are you aware that the old mysql_* extension is depreceated as of version 5.5 of PHP?

Is there any code acting on the input before it gets added to the database?

I don’t use DW so when you say that BOM is checked… does it mean that you’re sending BOM or not? You don’t want BOM

Thanks Phoenix, thans Molona. The problem is solved now. Molona I am still including BOM and this is not apparently causing the problem.

I was going through all the codes again and found that (I am working on someone’s code) that the mysql connection was getting called twice, once normally as we add a connect file on our top.php, and a second time using a mysql class of Ed Rackham.

In this mysql class, charsets was not defined. I added mysql_set_charset and did Set names there, and it got solved.

Further, yes its an old code, in the new codes I am using pdo.

Thanks a lot once again to both of you for your time :slight_smile: