Php 如何在数据库字段+mysql中获取realesacpe值
我试着像这样使用select查询来选择数据库中的数据Php 如何在数据库字段+mysql中获取realesacpe值,php,mysql,Php,Mysql,我试着像这样使用select查询来选择数据库中的数据 $qry ="select contact from sip_registrations where sip_user='1234567890'"; $sip_contact = mysql_query($qry); echo "<pre>"; while($row=mysql_fetch_assoc($sip_contact)){ print_r($row); } 但在数据库中,联系人字段值如下 Array (
$qry ="select contact from sip_registrations where sip_user='1234567890'";
$sip_contact = mysql_query($qry);
echo "<pre>";
while($row=mysql_fetch_assoc($sip_contact)){
print_r($row);
}
但在数据库中,联系人字段值如下
Array
(
[contact] => "1234567890" <sip:1234567890@192.XX.XXX.XX:XXXX;line=13fc8fc06d07efc;fs_path=sip%3A196.31.25.91%3Blr%3Breceived%3Dsip%3AXXX.XX.XXX.16%3A5066>
)
while($row=mysql_fetch_assoc($sip_contact)){
echo htmlentities($row['contact']);
}
实际上我需要像这样返回数组值
Array
(
[contact] => "1234567890" <sip:1234567890@192.XX.XXX.XX:XXXX;line=13fc8fc06d07efc;fs_path=sip%3A196.31.25.91%3Blr%3Breceived%3Dsip%3AXXX.XX.XXX.16%3A5066>
)
while($row=mysql_fetch_assoc($sip_contact)){
echo htmlentities($row['contact']);
}
你知道我需要做什么才能让这一切顺利吗?谢谢 因为字符串包含标记。要显示它,请使用将所有适用字符转换为HTML实体的
print_r(htmlspecialchars($row['contact']));
注意:-不推荐使用mysql,而使用mysqli或PDO
所有代码都运行良好。由于html标记,仅呈现html内容,而不显示 htmlspecialchars:PHP函数,用于将大于的预定义字符转换为HTML实体 用这个 而不是 打印r$行 不要使用mysql_*函数。请迁移到mysqli_*或PDO。联系人是什么字段类型?这对我来说没有意义,MySQL不会返回部分字段。