duanshan1511 2019-04-14 10:09
浏览 133

使用PHP从MySQL数据库打印出Unicode

I am trying to print out text and unicode. I get question marks as an output for all unicode. I do not want to replace it but I want to show the character that was put in it originally. Can someone tell me how? Using PHP and a MySQL database that has the correct symbols

Code:

if (!$db) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT * FROM `XP` ORDER BY totalxp DESC";
$result = mysqli_query($db, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        printf ('<div class="user">');
        printf ('<div class="content">');
        printf  ('<div class="profile_pic_holder">');
        printf ('<img class="profile_pic" src="' . $row["profilePic"] . '" >' . "<br>");
        printf ('</div><div class="text">');
#                          printf ("ID: " . $row["ID"] . "<br>");
        printf ($row["Nickname"] . "<br>");
#                          printf ("UserID: " . $row["UserID"] . "<br>");
        printf ("XP: " . thousandsCurrencyFormat($row["xp"]) . "<br>");
        printf ("Level: " . $row["level"] . "<br>");
        printf ('<div id="' . $row["UserID"] . '"></div>');
        printf ('<script>$("#' . $row["UserID"] . '").progressbar({value: ' . $row["percentageToNextLvl"] . ', "ui-progressbar-overlay": "./assets/lava.gif"});</script>');
        printf ("<br>");
        printf ('</div>');
        printf ('</div>');
        printf ('</div>');
    }
} else {
    echo "0 results";
}

DB is the Database connection How can I make it that the Nickname will be printed as unicode characters that are in the database and not just a question marks?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序