Mazz
Mazz

Reputation: 1879

utf8 to utf8mb4 mysqli charset php

I just converted my mysql database from utf8 to utf8mb4 so support Emojis, but now i have an encoding problem. If i print the text with php special characters are displayed normally, but they are saved as LATIN1 ü in the database

I followed this guide https://mathiasbynens.be/notes/mysql-utf8mb4

In php i set the charset like this after establishing the connection

 mysqli_set_charset($mysqli, "utf8mb4");

before converting, ä was saved as ä, ö was saved as ö and so on.

now its : ü -> ü and so on, so the common utf8 encoding problem.

mysql version is 5.5.46 so that souldn't be the problem

 database is utf8mb4_unicode_ci
 tabels are utf8mb4_unicode_ci
 varchar and text columns are also utf8mb4_unicode_ci

Upvotes: 1

Views: 5179

Answers (1)

Mazz
Mazz

Reputation: 1879

it seems that

  mysqli_set_charset($mysqli, "utf8mb4"); 

changed the charset to LATIN1 instead of utf8mb4, but with

  $mysqli->query("set names utf8mb4");

it is working fine

Upvotes: 4

Related Questions