0

I migrated a project to a new host. So I transferred my files and my database. But since then, my sql queries with accented characters no longer work (NULL):

php file:

$ product = 'Gestion réseaux sociaux';
$ handle-> query ('SELECT social_networks FROM sale WHERE id_customer = "'. $ id. '" AND product = "'. $ product. '"');

In addition, the accented characters displayed in the view from the database are not displayed correctly.

However, the rest of the written text content that does not come from the database displays the accented characters.

I still put the meta:

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

So I deduce that it comes from the encoding of the database but it is identical to that of my former host (UTF8_unicode_ci)

What can be the reason for you?

Thank you in advance for your help !!

  • Maybe it went wrong during the migration, or is it also not working for newly added data. Is the connection set up properly then? – GolezTrol Dec 30 '18 at 11:03
  • Which interface you are using? PDO, mysqli ? [mysqli_set_charset](http://php.net/manual/de/mysqli.set-charset.php) [pdo](https://stackoverflow.com/a/4361485/2575671) – Steffen Mächtel Dec 30 '18 at 11:15
  • To answer your questions : - I just tried with UTF16_general_ci but that does not change anything. - The data is displayed correctly in the database - The problem persists with newly added data   - I think the connection is correctly configured because the queries without accented characters work very well - My old host was Hostinger and the new host is OVH – Graine de Zèle Dec 30 '18 at 11:23
  • I use the mysql interface – Graine de Zèle Dec 30 '18 at 11:25

1 Answers1

0

It was enough to add "charset=utf8" to PDO

new PDO("mysql:host=$this->host;dbname=$this->dbname;charset=utf8", $this->user, $this->password);