2014-08-27 53 views
0

當我得到我的結果時,單引號出現爲特殊字符(問號?)有沒有辦法使它們正確顯示?這是我的代碼:wordpress mysqli_fetch_array在結果中沒有顯示單引號

while($row = mysqli_fetch_array($result)){ 
    $category1 = $row['category']; 
    $quer = "Select * from categories where id = $category1"; 
    $result1 = mysqli_query($con,$quer) or die ("Unable to execute query: $quer <br>Reason: It broke here!" . mysql_error()); 

    $category = mysqli_fetch_array($result1); 
    ?> 
    <span Style="Font-size: 25px; "><?php print $category['name']?></span><br> 
    <p><span class="headerLink">QUESTION</span><br> 
    <div class="bodytext" align="justify"><?php print $row['question']; ?></div></p> 
    <p><span class="headerLink">ANSWER</span><br> 
    <div class="bodytext" align="justify"><?php print $row['answer']; ?></div></p> 
    <div align="center"><a href="#top" class="topLink">&bull;&nbsp; Top &nbsp;&bull;</a></div><br> 

<?php 
    } ?> 
+0

什麼字符(多個)_exactly_您的意思是「單引號」?這很可能是一個字符編碼問題。 – CBroe 2014-08-27 14:48:49

+0

單引號字符(約翰的名字顯示爲約翰的名字) – 2014-08-27 20:43:35

回答

0

這裏是一對夫婦的事情,你可以嘗試:

設置文檔字符集的<head></head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

,並使用htmlentities

<span Style="Font-size: 25px; "><?php echo htmlentities($category['name'])?></span> 

您還應該使用$wpdb對象來篩選sql注入