1

I'm having trouble getting characters with accents to show up properly on my site. My site uses data from an Excel file that I dump into a MySQL DB. The tables in this DB are set to utf8_general_ci and I have the following in my head:

<meta charset="utf-8">

When I look at the data in PHPMyAdmin, everything looks fine, the characters show up. But on my site, characters such as ñ show up as a question mark in a black diamond.

I really don't understand what I'm doing wrong. Anyone know what's up?

user2874270
  • 1,312
  • 2
  • 18
  • 31

2 Answers2

1

By default, Mysql returns in Latin 1

try setting the values to utf8 after you're connected (in php) :

$db = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
mysql_set_charset('utf8', $db);
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");

Obviously, also make sure you declare your file as UTF8 in your head:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
Vincent Duprez
  • 3,772
  • 8
  • 36
  • 76
  • Thanks for the suggestions Vincent. Unfortunately I tried them all, emptied the database and reloaded it and I still have the problem – user2874270 Feb 23 '14 at 08:49
1

Figured it out! My source file for the data (a tab delimited text file from excel) needed to be re-saved in UTF-8. Once I did that, I was able to reload the data and get rid of the problem

user2874270
  • 1,312
  • 2
  • 18
  • 31