dpjs2005 2015-01-20 11:09
浏览 56

mysql查询的UTF-8编码 - 丹麦字符

I have tried for a while now to set the right encoding to show danish characters on my MySQL query. I haven't found exactly a similar situation.

My output shows a question mark instead of the appropriate characters. This is my connect file.

<?php 
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}   
?>

And here is my display file:

<?php
include("connect.php");
mysql_select_db("paradise",$con);
$result=mysql_query("SELECT * FROM CITATER4 ORDER BY RAND() LIMIT 1",$con);

while($data = mysql_fetch_row($result))
{   
echo "<aside class=\"citatout\">";
echo "<div id=\"paradiso\" class=\"text-vertical-center-q\">";
echo utf8_encode("<h1 class=\"animated fadeIn\" align=center>$data[0]</h1>");
echo utf8_encode("<h2 class=\"animated fadeIn\" align=center>$data[1]</h2>");
echo "</div>";
echo "</aside>";
}
?>

I tried to set the encoding using this code but it still didn't change. I found this in another question here on Stackoverflow.

mysql_set_charset("utf8", $con);

I encoded the strings in the displayed file with utf8_encode and it still doesn't work.

Do you have a solution?

  • 写回答

1条回答 默认 最新

  • doumanni3501 2015-01-20 11:54
    关注

    You should not be needing to use utf8_encode.

    Are your database tables utf8_danish_ci?

    Try running this mysql query in e.g. phpmyadmin.

    ALTER TABLE CITATER4 CONVERT TO CHARACTER SET utf8 COLLATE utf8_danish_ci;
    

    Does HTML5 have <meta charset="utf-8"> in the head tag?

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度