2016-09-27 59 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,拿出项目符号和将它们放回再次发现符号现在显示:)

我也加入到我的头

感谢所有帮助家伙:)