2014-08-27 66 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注入