Example mysql_query:
$query=mysql_query("SELECT `col1`, `col2` FROM `table` WHERE
`col1`='$escapedvariable' ");
I know the above is not good in practice.
Better query using prepare and execute
$pSt = $dbh->prepare('SELECT col1, col2 FROM table WHERE col1=:col1);
$pSt->execute(array(':col1'=>$escapedvariable);
$status=$pSt->errorCode();
Question: Can I use mysql_query with bound variables for added security?
prepare) is forPDO. Hence:col1as a bound parameter. If instead you are usingmysqlithen use?for bound parameters. mysqli parameters are not named - they are determined by their order in the sql.