0

When I run this sql from the MySql Admin panel:

UPDATE CH_HRA_questions SET question = '稱謂' WHERE q_id = 1

it works correctly, and in the table I can see the correct Chinese characters.

But when I run the same update statement from PHP, I get:

稱謂

The collation of the field is utf8_unicode_ci, any ideas what I'm doing wrong?

Many thanks

ojsglobal
  • 525
  • 1
  • 6
  • 31

2 Answers2

1

Try to set the PHP<->MySQL-connection charset.

If you are using the old MySQL API use mysql_set_charset('utf8_unicode_ci') (more).
If you use the MySQLi API use $mysqli->set_charset('utf8_unicode_ci') (more).

I also found out that $mysqli->query('utf8') can be working (here)...

Community
  • 1
  • 1
fnkr
  • 9,428
  • 6
  • 54
  • 61
0
$mysqli->set_charset("utf8");
zkanoca
  • 9,664
  • 9
  • 50
  • 94