ISO-8859-1 Character truncates text inserting into utf-8 mysql column

前端 未结 3 1174

So I have a weird truncate issue! Can\'t find a specific answer on this.

So basically there\'s an issue with an apparent ISO character ½ that truncates the rest of the

3条回答
  •  悲&欢浪女
    2021-01-28 09:22

    Did you call set_charset() on your MySQLi database connection? It's required to properly use real_escape_string().

    $db = new mysqli(...);
    $db->set_charset('utf8');
    

    Setting session variables in your connection is not enough -- those affect what happens on the server-side. The set_charset will affect what happens client side.

    You can checkout the PHP reference mysqli::real_escape_string

提交回复
热议问题