如何从mysql中提取包含特殊字符的数据? [英] how to extract data from mysql that contains special characters?

查看:216
本文介绍了如何从mysql中提取包含特殊字符的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中的示例数据:

Example data in my database:

blabla

我用的是phpmyadmin,可以看到数据已经输入成功.

I use phpmyadmin and can see that the data has been input successfully.

然而,当我尝试显示数据时,我得到的是:

However when I try to display the data what I get is:

blabla 不是 blabla

换句话说,< 符号之后的所有内容都不会显示.

In other words, everything after the < symbol does not display.

 <?
   while ($mouselist_row = mysql_fetch_array($mouselist)) {
   $mouselist_commonstrain = mysql_real_escape_string($mouselist_row['Common_Strain']);

    echo "$mouselist_commonstrain.";
}
   ?>

我尝试使用 mysql_real_escape_string.
是否有特别需要显示 < 的东西?谢谢

I tried using mysql_real_escape_string.
Is there something in particular needed to display the <? thanks

推荐答案

您的问题不是转义 SQL,而是 HTML.正如回答在这个问题你可以使用 htmlspecialchars 函数.

Your problem isn't escaping SQL but HTML. As answered in this question you can use htmlspecialchars function.

这篇关于如何从mysql中提取包含特殊字符的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆