PDO + MySQL and broken UTF-8 encoding

前端 未结 4 1001
孤独总比滥情好
孤独总比滥情好 2020-11-29 22:55

I use the PDO library with a MySQL database in PHP, but if I insert any data encoded in UTF-8, like Arabic words, it’s inserted into the database, but as ?????????

4条回答
  •  离开以前
    2020-11-29 23:31

    Try setting the default_charset value in php.ini to UTF-8. Or you can set it using the ini_set function.

    Also, if the input is coming through form submissions, make sure your web pages are set to UTF-8 using the meta tag.

提交回复
热议问题