gpt4 book ai didi

php - 一些字符(μ)显示为 ??.php/mysql

转载 作者:行者123 更新时间:2023-11-29 01:36:57 27 4
gpt4 key购买 nike

我正在尝试从 mysql 数据库中读取数据。在我的数据库中,我检查了数据显示为 'μ' 并且字符集正确设置为 'UTF-8'。但是当我在 PHP 中运行下面的代码时,输​​出 'μ' 显示为 '?'。我通过在脚本中添加不同类型的字符集尝试了很多方法,但都是徒劳的,它仍然显示为 '?'。谁能帮我解决这个问题。

我的脚本如下:

<?php
ini_set("default_charset", "UTF-8");
header('Content-type: text/html; charset=UTF-8');

error_reporting(E_ALL);
ini_set("display_errors", 1);

$tender_id=$_GET['tender_id'];

include('config_sqli.php');
?>
<?php
$result=mysqli_query($con,"SELECT * FROM comparitive_st_sup WHERE
id='$member[$x]' and tender_id='$tender_id'");
while($row=mysqli_fetch_assoc($result)){

$prod_description1 = $row['prod_description'];
$prod_description = mysqli_real_escape_string($con, $prod_description1);
}
echo $prod_description;
echo '<br>';
?>

最佳答案

试试这个,

在执行实际查询之前运行以下查询:

mysqli_query($con, "SET NAMES 'utf8'");

试试你的 mysqli 连接

$mysqli = new mysqli("localhost", "root", "", "test");
$mysqli->set_charset("utf8");
// be careful, this method can be not working (mantainers builds bugs for old php releases), first example is works fine

希望对您有所帮助。

关于php - 一些字符(μ)显示为 ??.php/mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39444102/

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