gpt4 book ai didi

php 使用 mysqli 搞乱 mysql 数据库中的 utf-8 字符

转载 作者:行者123 更新时间:2023-11-29 14:48:04 28 4
gpt4 key购买 nike

我有一些中文字符(例如中文(简体))存储在内容类型为utf8_bin的mysql数据库中。

我使用以下代码从数据库中提取数据:

if($stmt = $mysqli->prepare("SELECT c_color FROM colors")){
$stmt->execute();
$stmt->bind_result($ccolor);
$stmt->store_result();
if($stmt->fetch()){
//$ccolor is filled with question marks
}

我做错了什么?我有

header('Content-type: text/html; charset=UTF-8') ;

并且页面上显示汉字。看起来像是 php 的问题。

最佳答案

您可能还需要将连接设置为使用 utf-8。您可以在配置中设置它,或者使用this function进行设置。 .

更多信息:here .

关于php 使用 mysqli 搞乱 mysql 数据库中的 utf-8 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6436033/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com