gpt4 book ai didi

php - SELECT 语句不适用于 utf-8

转载 作者:可可西里 更新时间:2023-10-31 23:46:42 24 4
gpt4 key购买 nike

<分区>

我有一个 select 语句,它应该选择数据库中等于阿拉伯语输入的所有数据,我已经将数据库的排序规则设置为 utf8_general_ci 和表列作为确定。并在文件中

$conn = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database); 
mysqli_query($conn, "set names 'utf8'");
mysqli_query($conn, "SET character_set_results=utf8");
mb_http_output('UTF-8');
mb_internal_encoding('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');
mb_language('uni');
mb_internal_encoding('UTF-8');
mysqli_set_charset($conn, "utf8");

以及搜索的代码

$question = $_REQUEST['question'];
$table = $_REQUEST['subject'];
if(empty($question)) {
echo "Type a question!"; }
$qe = mysqli_escape_string($conn, $question);
$full = "SELECT * FROM $table WHERE question LIKE '%$qe%'";
$fullQ = mysqli_query($conn, $full);
if(!$fullQ) {
echo mysqli_error($conn);
}
echo "<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>";
printf(nl2br("\n%u\n"), mysqli_num_rows($fullQ));
while($row = mysqli_fetch_assoc($fullQ)) {
printf(nl2br("\n%s\n"), $row['question']);
}

如果我在不使用 WHERE 的情况下打印所有数据,它会工作,并且它还会在从第一页发送到第二页后使用正确的阿拉伯字符打印 SQL 语法。但它总是返回 0 行。

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