正确地从数据库请求中去除斜杠
我的数据库中存储了包含斜杠的消息:例如 don\t
为了显示消息,我使用此过程。问题是反斜杠仍然显示。 我怎样才能摆脱它。 我尝试了很多事情,并阅读了这里的几篇文章,但无法让它发挥作用。这里有人帮助我并告诉我什么是最好的方法..
$msg2 = html_entity_decode($row3[comment]);
echo stripslashes(nl2br($msg2));
I have message stored in my database containing a slash: e.g. don\'t
To present the message I use this procedure. The thing is the backslash is still displayed.
How can I get rid of it.
I have tried many things, and read several postings here, but can't get it to work. Anyone here to help me and tell me what is the best way..
$msg2 = html_entity_decode($row3[comment]);
echo stripslashes(nl2br($msg2));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将它们存储在数据库中时,应将它们存储为
mysql_real_escape_string($phpString)
。为什么要使用
html_entity_decode
来实现此目的?这里只要stripslashes
就足够了。When storing them in the database, you should store them as
mysql_real_escape_string($phpString)
.Why do you use
html_entity_decode
for this? Juststripslashes
should be sufficient here..