我遇到了一个奇怪的问题,当从我的 mysql 数据库中检索任何内容并在 php 脚本中回显时,记录中的引号将被 Google Chrome 中的菱形问号替换。
我的 mysql 数据库设置为排序规则:utf8_general_ci
下拉记录的脚本部分如下:
<?php
echo '<div class="testimonialswrapper">';
// Retrieve Page Content //
$testimonialssql = <<<SQL
SELECT *
FROM `testimonials`
ORDER BY id DESC
LIMIT 5
SQL;
if(!$resulttestimonials = $db->query($testimonialssql)){
die('There was an error running the query [' . $db->error . ']');
}
while($rowT = $resulttestimonials->fetch_assoc()){
if ($rowT['company'] == ''){$name = $rowT['name'];}else{$name = $rowT['name'].' - '.$rowT['company'];}
$from = $rowT['from'];
$message = $rowT['message'];
echo '<p class="testititle">'.$name.'</p>';
echo '<p class="testifrom">'.$from.'</p>';
echo '<p class="testimessage">'.$message.'</p>';
}
echo '</div>';
?>
这包含在我的 index.php 中,它具有以下设置:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
我尝试过使用 htmlenteties 和 stripslashes 以及其他各种东西,但仍然遇到同样的问题。