So I know that using prepared statements with placeholders is pretty much the only way to protect yourself from SQL injection due to poor formatting of your queries. However, I also see many people suggesting that, although mysqli_real_escape_string is NOT safe, using it with single quotes around the variable is. For example (note the single quotes in the query):
$value1 = mysqli_real_escape_string($value1); $value2 = mysqli_real_escape_string($value2); $value3 = mysqli_real_escape_string($value3); mysqli_query("INSERT INTO table (column1, column2, column3) VALUES ('" . $value1 . "', '" . $value2 . "', '" . $value3 . "')"; So: when only dealing with integers and strings, would the above example be just as safe as if you were to use mysqli prepared statements and placeholders?
mysql_real_escape_stringis also safe because it properly formats any possible string or integer.