0

I working on a website project using Bootstrap 3. The character set I am using on my html pages is utf8. On localhost, I am using MySQL56 where the database for the project has utf8 as character set and utf8_general_ci as collate.

On the remote server, the database I created has the same character set and collate.

When I am doing test on local, the characters appear well but when I am doing the test on remote server, I get diamonds on some characters like 'é' or 'è'. Also, when I write data into the database table, those characters doesn't appear well in PHPMyAdmin, but everything is fine on my computer.

I don't understand where the problem comes from and how to fix it.

Thank you.

Patrik
  • 401
  • 1
  • 6
  • 23

1 Answers1

2

Make sure you're setting PHP headers correctly;

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

You can either place this in a common include in PHP or edit your PHP.ini file and modify/add this line;

default_charset = "utf-8";
Community
  • 1
  • 1
Novocaine
  • 4,692
  • 4
  • 44
  • 66
  • The default_charset in my PHP.ini is already set to utf8. I wrote the header you provided at the top of all my webpage (just after the session_start() function) but I got no results. – Patrik Dec 07 '15 at 10:41
  • You could check this url: http://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql are your database transactions all set to utf-8 too? – Novocaine Dec 07 '15 at 10:58
  • I read the article from the url you provided and every works fine now, thanks – Patrik Dec 07 '15 at 13:09
  • Great, was there any specific issue, or were there a bunch of things to do? – Novocaine Dec 07 '15 at 13:43
  • 1
    I had to specify the charset=utf8 in the database connection. As I am using PHP with PDO that is: mysql:host=localhost;dbname=ccbokdot_memccb;charset=utf8 in the PDO constructor – Patrik Dec 07 '15 at 14:20