Im simply passing user data into an SQL database and collecting the data for admin view only, i am usin mysql_real_escape_string() to escape the data, I was told today that htmlentities is better to use, i have always heard the opposite. could do go a little more in depth on this with me. Also as a sid enote, if someone could provide a really good tutorial for PDO that would be wonderful
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率

已采纳
我应该使用htmlentities还是mysql_real_escape_string [关闭]
收起
- 写回答
- 好问题 0 提建议
- 关注问题
微信扫一扫
点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
2条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
dongzhuanlei0768 2013-01-12 18:45关注The two do entirely different things. One escapes data for putting into a SQL statement (which is a bad in general: see http://bobby-tables.com) and the other escapes data for putting into an HTML document. You're basically asking "Should I use a spoon or a fork?"
本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫
点击复制链接分享
评论按下Enter换行,Ctrl+Enter发表内容
报告相同问题?
提交
- 2012-09-07 18:34回答 1 已采纳 Instead of using if( $this->real_escape_string ) { // PHP v4.3.0 or higher check php version
- 2013-04-12 11:48回答 2 已采纳 Still trying to understand what you mean by "sending the $_SESSION", but this statement looks weir
- 2015-01-24 16:35回答 1 已采纳 This part of your script '%search_term%' is missing the $ change that to '%$search_term%' and r
- 2017-06-27 17:05luoxiandong2的博客 mysql_real_escape_string和mysql_escape_string区别 两者都是过滤字符串,防止sql注入,但两者有一些区别 mysql_real_escape_string: 1.具有两个参数,其中第二个为选填参数,默认为上一个数据库链接...
- 2010-10-13 14:26回答 1 已采纳 Given that error message, the $db_query you're passing in to the tep_db_fetch_array() is obviously
- 2015-10-08 15:48回答 3 已采纳 Change echo 'Error creating user: ' . $link->connect_error . " "; to echo 'Error creating u
- 2012-06-19 08:32回答 3 已采纳 From manual mysql_close Using mysql_close() isn't usually necessary, as non-persistent open li
- 2021-02-10 02:00lvero王的博客 例如,O'Reilly在传送给MySQL数据库前需要转义成O\'Reilly。单引号前的反斜杠代表单引号是数据本身的一部分,而不是并不是它的本义。我所指的输出转义具体分为三步:l 识别输出l 输出转义l 区分已转义与未转义数据只...
- 2014-11-18 13:55回答 1 已采纳 Try looking at the example supplied by PHP.net: <?php $mysqli = new mysqli("localhost", "my_us
- 2015-05-25 03:51回答 1 已采纳 You need to add a condition to your query, ie. WHERE characters.character_owner = users.user_id
- 2011-02-05 18:05回答 4 已采纳 Use AND instead of && And use sprintf to protect your variables: sprintf("SELECT * F
- 2021-02-07 08:30weixin_39863017的博客 这比使用转义功能(例如)更加安全mysql_real_escape_string。是的,mysql_real_escape_string实际上只是一个字符串转义功能。这不是魔术子弹。它所要做的就是逃避危险字符,以便可以安全地在单个查询字符串中使用它们...
- 2021-02-10 02:00意博思诺教育的博客 MySQL的对于我的实验目的,我已经在我自己的网站上尝试了少量的XSS注射。...如果我仅应用strip_tags和mysql_real_escape_string,并且在将数据插入到数据库之前,不要在我的输入上使用htmlentities,所以查...
- 2021-02-10 02:00程序员必修课的博客 平台: PHP和mySQL出于实验目的,我在自己的网站上尝试了很...如果仅在将数据插入数据库之前才应用strip_tags和mysql_real_escape_string并且不对输入使用htmlentities,则查询将中断 ,由于异常终止,我会遇到一个...
- 2011-09-08 10:42manbujingxin的博客 mysql_real_escape_string() 函数转义 SQL 语句中使用的字符串中的特殊字符。 下列字符受影响: \x00\n\r\'"\x1a 如果成功,则该函数返回被转义的字符串。如果失败,则返回 false。 ____________
- weixin_39788960的博客 过滤的延深 就是转义,有些数据... $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = "SELECT * FROM profile WHERE username = '{$mysql['username']}'"; $result = mysql_query($sql); ?>
- 2021-04-23 16:26findtea的博客 我有用户输入并使用htmlentities()来转换所有实体.但是,似乎有一些错误.当我输入ääää öööö üüüü ääää我明白了ääää öööö üüüü ääää看起来像这样Ã...
- 2021-02-07 15:33胡匪的博客 从 PHP5.5.0 开始已经不推荐使用 mysql_real_escape_string() 了,所有新的应用应该使用 MySQLi 和 PDO_MySQL 扩展提供的方法:mysqli_real_escape_string() 或者 PDO::quote() 函数库执行数据库操作,以防止...
- 2016-11-22 23:36weixin_33895475的博客 包括(‘), (“), (), (NUL)四个字符,此函数在DBMS没有自己的转义函数时候使用,但是如果DBMS有自己的转义函数,那么推荐使用原装函数,比如MySQL有mysql_real_escape_string()函数用来转义SQL。 注意在PHP5.3之前,...
- zf213的博客 如果你的站点没有使用严格的用户输入检验,那么常容易遭到SQL注入攻击。SQL注入攻击通常通过给站点数据库提交不良的数据或查询语句来实现,很可能使数据库中的纪录遭到暴露,更改或被删除。为了防止SQL注入攻击,PHP...
- 没有解决我的问题, 去提问