我使用默认插入 MySQL 数据库排序规则 latin1_swedish_ci 的泰米尔语言 (utf-8)。但数据显示像??? ??? ????????????.??????当我取回它时。我在网上研究了很多关于这个问题的内容。但解决方案没有任何用处。完全让人抓狂。任何人都可以帮助我。我正在使用下面这样的查询。仅以简单的方式给我解决方案。
<?php
$con=mysql_connect('localhost','root','');
$db=mysql_select_db('nikah', $con);
$sql="select * from matrimony";
$result=mysql_query($sql) or die(mysql_error());
While($row=mysql_fetch_array($result)){
echo $row['name'];
}
?>
最佳答案
按照说明尝试使用 mysql_set_charset()
here .
$link = mysql_connect('localhost', 'user', 'password');
mysql_set_charset('utf8',$link);
编辑: 正如 Jay 所说,请记住 mysql 扩展在 PHP 5.5.0 中已被弃用。来自 php 文档:
Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: mysqli_set_charset() PDO: Add charset to the connection string, such as charset=utf8
关于php - 如何检索 utf-8 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34774097/