Should I use mysqli_real_escape_string or should I use prepared statements?

Ali picture Ali · Apr 3, 2013 · Viewed 8.9k times · Source

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?

Answer

Yogesh Suthar picture Yogesh Suthar · Apr 3, 2013

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