I have a BUNCH of $_POST variables being sent in via a long form and instead of hard coding each one with a mysql_escape_string()
is it ok for me to do the following? I don't know if this is actually safe and/or viable code.
foreach ($_POST as &$post_item){
$post_item = mysql_escape_string($post_item);
}
I'm fairly certain that because i'm using the &, it's passing it in by reference, not value, so i'm actually changing the value in the $_POST.
Also, should I use mysql_real_escape_string()
instead?
EDIT: I am using PDO and prepare() along with the above method. Does this take care of it for me?