如何从MySQL数据库中获取“印地语”(印度当地语言)हिन्दी网站文字
当我从数据库中获取数据时显示
???????????????????????????????????????
????????????????????????
??????????????????????????????????????
??????????????????????????????????????
参考这个问题,我已将我的数据库字符集更改为“utf8_unicode_ci”,但仍无效。我编写了以下代码来获取数据
connection.php page
<?php
$DB_HOST = 'localhost';
$DB_USER = 'xxxxxxxx_usr';
$DB_PASS = 'xxxxxxxxxxxxxxxxx';
$DB_NAME = 'xxxxxxxs_dta';
try{
$DB_con = new PDO("mysql:host={$DB_HOST};dbname={$DB_NAME}",$DB_USER,$DB_PASS);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo $e->getMessage();
}
index.php page
<?php include("../header.php"); ?><style>
.wrapper{position:relative;}
.right,.left{width:50%; position:absolute;}
.right{right:0;}
.left{left:0;}
</style> <?php
require_once 'connect.php';?>
<link href='/Lang/style.css' rel='stylesheet' type='text/css'>
<?php
$iddd =$_GET['id'];
$d = $browser_t; ?>
<div class="content">
<div class="dta">
<?php
mysqi_set_charset( $DB_con, 'utf8');
$stmt = $DB_con->prepare('SELECT id, title, post, viewers, author, external FROM getpost WHERE id =:vid');
$stmt->execute(array(':vid'=>$iddd));
$stmt->execute();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="list_item"><h2><?php echo $row['title']; ?> Tutorials</h2></div>
<div class="nykfont"> </div>
<?php echo $row['post']; ?>
<div class="content">
<div class="dta">
<div class="nykfont">
<div class="lis_ite"><?php echo $row['external']; ?></div>
<div class="listt_itemm">Author<h5><a href="http://www.mrtutorials.net/Author/<?php echo $row['author']; ?>"><?php echo $row['author']; ?></a></h5></div></div>
<?php
}
}
else
?>
</div></div>
<hr>
<?php include("../footer.php"); ?>
答案 0 :(得分:0)
这解决了我同样的问题。
ALTER TABLE tablename
CHANGE COLUMN columnname VARCHAR(45) CHARACTER SET 'utf8' ;