Is mysql_real_escape_string sufficient for cleaning user input in most situations?
::EDIT::
I’m thinking mostly in terms of preventing SQL injection but I ultimately want to know if I can trust user data after I apply mysql_real_escape_string or if I should take extra measures to clean the data before I pass it around the application and databases.
I see where cleaning for HTML chars is important but I wouldn’t consider it necessary for trusting user input.
T
mysql_real_escape_stringis not sufficient in all situations but it is definitely very good friend. The better solution is using Prepared StatementsAlso, not to forget HTMLPurifier that can be used to discard any invalid/suspicious characters.
………..
Edit:
Based on the comments below, I need to post this link (I should have done before sorry for creating confusion)
mysql_real_escape_string() versus Prepared Statements
Quoting:
Chris Shiflett (Security Expert)