This is sample code:
include("db_connect.php");
//
function foo($string){
$s_array = array("'", '"');
$result = str_replace($s_array, "\\", $string);
return $result;
}
//
$first_var = $_POST['first_var'];
$second_var = intval($_POST['second_var']);
//
$first_var_result = foo($first_var);
//
mysql_query("UPDATE some_table SET first_column='".$first_var_result."', second_column='".$second_var."' WHERE id='id'");
When $_POST['first_var'] equals ', foo function replaces ' with \ and mysql returns ERROR. This is not my code. I'm simpe interested in if this code is vulnerable (SQL Injection)? Thanks.