0

I have a database that contains some Greek characters. These are displaying as question marks in the browser.

I'm setting the content type in html as

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

I'm also sending a header of

header('Content-Type: text/html; charset=utf-8');

My database has CHARACTER SET utf8 COLLATE utf8_unicode_ci

The only way I can get it working is if I use the queries below but it's not ideal.

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");

Do I need to do anything else on the database?

jhodgson4
  • 1,566
  • 3
  • 20
  • 35
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Mar 26 '14 at 11:31
  • 1
    *"The only way I can get it working is if I use the queries below but it's not ideal."* - What's not ideal about that? – deceze Mar 26 '14 at 11:31
  • It would be best not to use the deprecated `mysql_` functions at all, but `mysqli_` functions or even PDO, which allows you to set the `PDO::MYSQL_ATTR_INIT_COMMAND`. – TheWolf Mar 26 '14 at 11:33
  • @deceze unfortunately its an old app in which there is no shared file. I'd have to go through every file with which there are many. – jhodgson4 Mar 26 '14 at 11:39
  • @TheWolf Agreed but it's not an option for this project – jhodgson4 Mar 26 '14 at 11:39
  • You can try to set the same configuration options as default in the MySQL server configuration file, but that may be even less of an option. Fact is, the connection encoding needs to be set, no way around it. You may have to refactor a bit there. – deceze Mar 26 '14 at 11:49

0 Answers0