Heim  >  Artikel  >  Backend-Entwicklung  >  见鬼了,真的是百思不得其解,难道是bug?该怎么处理

见鬼了,真的是百思不得其解,难道是bug?该怎么处理

WBOY
WBOYOriginal
2016-06-13 13:42:56746Durchsuche

见鬼了,,真的是百思不得其解,难道是bug???
一段语句

$str='

<span style="color:red">123</span>
';

在临插入数据库的时候我打印出来,,观看源代码就是这样的,

诡异的是

存入数据库后,,在显示出来,源代码居然变成

<span style="color:red">123</span>


而数据库里存的也是这个,,真是邪门了。。。。

难道bug??

------解决方案--------------------
我打印出sql语句都没问题
-----------------------
确定浏览器源代码里看这行输出
也没转化?
<br><font color="#e78608">------解决方案--------------------</font><br><br>看数据库数据是否正常。<br>不正常检查:<br>echo $sql 之后 INSERT之前有没实体化了。<br><br>正常:<br>即是实体化输出了。
<br><font color="#e78608">------解决方案--------------------</font><br>转义字符的问题吧。<br><br>使用addslashes函数将数据插入到数据库中,读取时使用stripslashes函数还原为正常的数据。
<br><font color="#e78608">------解决方案--------------------</font><br>TP入库自动处理了的吧
<br><font color="#e78608">------解决方案--------------------</font><br>同意楼上的,是为了防止SQL注入式攻击。上次的加那个转义没有用的。不过好像把标签的""(。<pre class="brush:php;toolbar:false">)替换为"&\lt","&\gt"。这样既可以正确显示代码,又不会使代码被执行
<br><font color="#e78608">------解决方案--------------------</font><br>你用thinkphp ,thinkphp的插入都把标签给转换了 <div class="clear">
                 
              
              
        
            </div>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn