When is the correct time to use mysql_real_escape_string?
Should I be using it when I use isset(mysql_escape_string($_GET[‘param’])),
Should I be using it when I use $foo = mysql_real_escape_string($_GET[‘bar’]);
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to call this function when building SQL queries with string literals.
You should not call it anywhere else.
The point of calling this function is to prevent you from executing SQL like
SELECT * FROM Students WHERE Name = 'Robert'); DROP TABLE Students;--'.mysql_real_escape_stringwill escape the'character so that the evil string is treated entirely as a string.