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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条