这是我的问题,我有一个阿拉伯数据库 mysqli UTF8_general_ci 并且我的 php 文件的字符集是 UTF-8
当我出售数据时,我得到“????????????”。
在 php 上,我的管理员我可以毫无问题地写入和读取,在 php 上我也可以,但问题是当我从数据库获取数据时!这是我的代码:
<meta charset="UTF-8"/>
$connexion = new mysqli(HOST_DB,USER_DB,MDP_DB,DB_NAME);
if ($connexion->error) {
die('Une erreur s\'est produite :' .$connexion->error);
}
else{
$sql = "SELECT nom, description, date, formateur, image, prix, lieux FROM news";
if ($result = mysqli_query($connexion,$sql)) {
while ($ligne = mysqli_fetch_assoc($result)) {
echo'
<ul>
<li><figure>
<figcaption>
<h1>'.$ligne["nom"].'</h1>
<p>'.$ligne["description"].'</p>
<strong>اليوم:'.$ligne["date"].'</strong><br/>
<strong>المكان:'.$ligne["lieux"].'</strong><br/>
<strong>المدرس:'.$ligne["formateur"].'</strong><br/>
<strong>الثمن: '.$ligne["prix"].'دينار</strong>
</figcaption>
<img src="Images/'.$ligne["image"].'" height="250px" width="250px">
</figure></li>
</ul>
';
}
}
}
将此代码放在连接到mysql之后。
mysqli_set_charset($connexion,'utf8');
这是连接数据库的最终代码:
$connexion = new mysqli(HOST_DB,USER_DB,MDP_DB,DB_NAME);
mysqli_set_charset($connexion,'utf8');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)