我遇到了一个问题,无法在mysql表格中显示html标签。我尝试使用addslashes、mysql_real_escape_string和stripslashes来正确查看标签,但是每次通过浏览器查看数据时,它都会显示html的文本。例如:
我在mysql数据库表中有这个内容:
<strong>Test</strong>
在网页中查看时应该显示为:测试
但实际上,它显示为<strong>测试</strong>
我用的 PHP 代码来显示内容是:
<?php
require_once("inc.php"); //This includes the configuration for mysql database
?>
<html>
<head>
</head>
<body>
<p>
<?php
$conn = mysql_connect(HOST,USER,PASS) or die(mysql_error());
mysql_select_db(NAME) or die(mysql_error());
$sql = "SELECT * FROM events";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query)){
echo(stripslashes($row['details'])); //The details is what contains the <strong>Test</strong>
}
mysql_close($conn) or die(mysql_error());
?>
</p>
</body>
</html>