The symbols I should be aware of for SQL injection

后端 未结 2 782
梦如初夏
梦如初夏 2021-01-26 14:03

I know that you cure all of the stuff with mysql_real_escape_string() (and with htmlspecialchars()), but I want to know the symbols that cause all this

相关标签:
2条回答
  • 2021-01-26 14:56

    Each DB will have its own metacharacters as extensions to standard SQL syntax. Some will use -- for comments, some use c-style /* */, etc... Each DB has its own escaping requirements, which is why there's an escape function for every DB type in PHP. What works for MySQL may be completely useless for (say) Oracle.

    The only "definitive" list of characters will be the ones listed in the SQL standards. But using only those in your own custom escape function would be useless, because it won't include the DB-specific non-standard metacharacters that the DB understands.

    0 讨论(0)
  • 2021-01-26 14:57

    From the PHP Manual:

    mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.

    0 讨论(0)
提交回复
热议问题