2016-09-27 61 views
1

所以我不知道爲什麼,但是當我把我的網站從離線突然在線時,網站不會顯示任何符號,我不知道爲什麼。它在線下很好地工作。之前:(整個網站從MySQL檢索到的數據庫數據中的符號

enter image description here 我的header.php

<?php 
header('Content-Type: text/html; charset=UTF-8'); 
echo <<<_END 

<!DOCTYPE html> 
<html> 
<head> 
    <title>$title</title> 
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet"> 
    <link href="bootstrap/css/bootstrap-theme.css" rel="stylesheet"> 
    <link href="style.css" rel="stylesheet"> 
</head> 
<body> 
_END; 

和index.php文件確實找不到對這個從未見過的任何信息

<?php 
$title = 'Baz Building'; 
require_once 'header.php'; 
require_once 'nav.php'; 
?> 
<div class="container"> 
    <h1>Welcome to baz Build by Richard Hayward</h1><br><br> 
    <div class="col-8"> 
     <h2 class="text-center">Houses</h2> 
    </div> 
    <div> 
     <ul class="list-group"> 
     <?php 
     //Get connection details from file 
     require_once'mysqli-con.php'; 
     //Create new connection 
     $conn = new mysqli($hn, $un, $pw, $db); //Create new object, MYSQLI connection 
     if ($conn->connect_error) die ($conn->connect_error); //Display error if failed to connect 


     // Create first query to get all house names for count 
     $query_names = $conn->query('SELECT name FROM house_names'); // Query all names data 
     $num_rows = $query_names->num_rows; // Get the number of rows for loop 

     //Start loop for output of each item 
     for($c = 0 ; $c < $num_rows ; ++$c){ 

      //Query Join 
      $query_names->data_seek($c); 
     $name = $query_names->fetch_array(MYSQLI_NUM); 

      $query = "SELECT house_names.id, house_names.name, houses_has_features.house_names_id, house_types.type, features.feature FROM house_names 
JOIN houses_has_features 
ON house_names.id = houses_has_features.house_names_id 
JOIN house_types 
ON house_types.id = houses_has_features.house_types_id 
JOIN features 
ON houses_has_features.features_id = features.id 
WHERE house_names.name = \"$name[0]\""; 


      $query_join = $conn->query($query); 

     $rows = $query_join->num_rows; 

     echo '<p>'; 

      //Output name and type for each item 
     $first_rows = $query_join->fetch_array(MYSQLI_ASSOC); 
     echo '<li class="list-group-item active">' . $first_rows['name'] . '</li>'; 
     echo '<li class="list-group-item"><b>Type: </b>' . $first_rows['type'] . '</li>'; 
     echo '<li class="list-group-item"><b>Features: </b>'; 
     for($j = 0 ; $j < $rows ; ++$j) //Features loop 
     { 
      $query_join->data_seek($j); 
      $row = $query_join->fetch_array(MYSQLI_NUM); 

      //Output all features for each item 
     echo $row[4] . ', '; 
     }; 
     }; 


     // Close objects 
     $conn->close(); 
     $query_join->close(); 
     $query_names->close(); 


     ?> 
     </ul> 
    </div> 
    </div> 
</body> 
</html> 
+2

你可能在Ÿ非UTF8字符我們的數據庫也許你的數據庫有錯誤的編碼。 –

+0

oooh也許是DB。我將頁面設置爲UTF8 – RiCHiE

+0

服務器連接歸類文檔:UTF8_general_ci – RiCHiE

回答

2

這是unicode的一篇文章,是值得閱讀:The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets

單一最重要的事實Abo ut編碼

如果你完全忘記了我剛纔解釋的一切,請記住 一個極其重要的事實。在不知道使用什麼編碼的情況下使用字符串 沒有任何意義。你不能再把你的 頭放在沙子裏,並假裝「純文本」是ASCII。

有沒有這樣的事情作爲純文本。

+0

好的,謝謝你們我在這方面找不到任何數據,但似乎有很多,我真的只需要至少指出正確的方向,因爲我不知道這是來自哪裏,謝謝你的幫助 – RiCHiE

1

檢查的相對路徑和網址是WWW OT加www

+0

沒有但我用www試過,似乎沒有什麼區別。 – RiCHiE

0

好了,所以讀取後(感謝您的鏈接)後,我切換數據庫utf8mb4_bin,拿出項目符號和將它們放回再次發現符號現在顯示:)

我也加入到我的頭

感謝所有幫助傢伙:)