I want to eliminate sql injection, should I use mysqli_real_escape_string() or is it clear in mysqli?
For example
$nick = mysqli_real_escape_string($_POST['nick'])
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 should use prepared statements and pass string data as a parameter but you should not escape it.
This example is taken from the documentation:
Note that the example does not call
mysqli_real_escape_string. You would only need to usemysqli_real_escape_stringif you were embedding the string directly in the query, but I would advise you to never do this. Always use parameters whenever possible.Related