douli1872 2010-07-12 16:10
浏览 23
已采纳

我是否需要在数据库数据上使用mysql_real_escape_string重新插入?

Hello and thanks in advance.

I am retrieving data from the db. The data already went through mysql_real_escape_string when it was added to the db.

Once retrieved I am comparing it to a raw variable and depending upon the result I may be re-inserting the original db data back into the db into another, different, field.

My question is, do I have to use mysql_real_escape_string on this data I got from the database?

I think yes as the data could contain characters that need to be escaped and I think the backslashes are not stored in the db.

My code is:

if(isset($row['location_uri']) && $row['location_uri'] != $location_uri)
    {
    $session_previous_page = $row['previous_page_uri'];
    }
else
    {
    $session_previous_page = $row['location_uri'];
    }

Also, should I do anything with the db data before I compare it to the raw data, say from $_SERVER['REQUEST_URI']?

thanks for any help you can give.

  • 写回答

2条回答 默认 最新

  • dongxibeng5324 2010-07-12 16:14
    关注

    You should re-apply it. The escaping functions put in slashes, etc. so it is valid SQL syntax. Those slashes aren't actually stored in the database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图