我有一個奇怪的問題,當我的mysql數據庫中的任何東西都被檢索到並且在php腳本中出現echo'd出現在記錄中的引號被谷歌瀏覽器中的菱形問號所取代。來自數據庫的引號在Chrome中作爲鑽石問號被echo'd出來
我的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和其他各種東西試過,但還是有同樣的問題。
旁邊的字段說utf8_general_ci和文本只是純文本複製並從他們的舊網站粘貼到phpmyadmin。 –
您還沒有閱讀過鏈接的文章。你錯過*連接編碼!* – deceze
謝謝!,這工作mysqli_set_charset($ db,'utf8'); –