用撇号回显mysql中的文本

时间:2014-05-29 19:49:02

标签: php mysql

您好我正在尝试回显一些我放入包含撇号的mysql的文本。然而,每当我尝试回显文本时,撇号都会被替换为方框。     

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT * FROM rules";
$result = mysqli_query($link, $query);

while($row =  $result->fetch_array()) {
    echo '<article class="content grid_10 push_1">';

    echo '<h1>';
    echo $row['title'];
    echo '</h1>';

    echo '<section>';

    echo nl2br(stripslashes($row['post']));

    echo '</section>';
    echo '</article>';

}?> 

1 个答案:

答案 0 :(得分:0)

试试这个(用utf-8编码):

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT * FROM rules";
$result = mysqli_query($link, $query);

while($row =  $result->fetch_array()) {
    echo '<article class="content grid_10 push_1">';

    echo '<h1>';
    echo utf8_encode($row['title']);
    echo '</h1>';

    echo '<section>';

    echo nl2br(stripslashes(utf8_encode($row['post'])));

    echo '</section>';
    echo '</article>';

}?>