Should I use mysqli_real_escape_string or should I use prepared statements? [duplicate]

偶尔善良 提交于 2019-11-30 18:01:06

问题


Should I use mysqli_real_escape_string or should I use prepared statements?

I've seen a tutorial now explaining prepared statements but I've seen them do the same thing as mysqli_real_escape_string but it uses more lines

Are there any benefits for prepared statements? What do you think is the best method to use?


回答1:


Prepared statements only. Because nowhere escaping is the same thing. In fact, escaping has absolutely nothing to do with whatever injections, and shouldn't be used for protection.

While prepared statements offer the 100% security when applicable.




回答2:


Use prepared statements because after using this you doesn't have to use mysqli_real_escape_string. prepared statements doing this as by default.




回答3:


It's very easy to forget (maybe not for you, but other developers you work with) to escape whereas it's very hard to use prepared statements incorrectly to cause a vulnerability. So prepared statements.



来源:https://stackoverflow.com/questions/15786295/should-i-use-mysqli-real-escape-string-or-should-i-use-prepared-statements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!