UTF-8 Database Problem

前端 未结 3 524
终归单人心
终归单人心 2020-12-21 05:30

I\'ve a MySQL table that has a UTF-8 charset and upon attempting to insert to it via a PHP form, the database gives the following error:

PDOStatement:

3条回答
  •  伪装坚强ぢ
    2020-12-21 06:26

    Before passing the value to Mysql you can use the following code:

    $val = mb_check_encoding($val, 'UTF-8') ? $val : utf8_encode($val);

    convert the string the to UTF-8, If it's matter of only one field.

提交回复
热议问题