What's the best way to use mysql_real_escape_string, is it at the beginning like this:
$email = mysql_real_escape_string($_POST['email']);
$qemail = mysql_query ("SELECT email FROM ppl WHERE email='$email'");
or at the end like this:
$email = $_POST['email'];
$qemail = mysql_query ("SELECT email FROM ppl WHERE email='". mysql_real_escape_string($email) ."'");
The whole website is using mysql so I have to keep it in mysql. The problem is, I don't want to use mysql_real_escape_string everywhere (the code looks confusing and horrible). I would like to use it only at the beginning for $_POST, but is that enough?
Some people suggest that it's best to use it in queries, but I fail to see why.