I’m working on a PHP MSSQL project that is using the sqlsrv driver.
What’s the best way to stop SQL injection attacks? I need something like mysql_real_escape_string() but for sqlsrv driver.
I’m working on a PHP MSSQL project that is using the sqlsrv driver. What’s
Share
The best way is not to write your SQL so that you need to use an analogue of
mysql_real_escape_string(), which you would do by using placeholders for the values and then passing the variables (that would otherwise have been handled bymysql_real_escape_string()) when you execute the statement or open the cursor or whatever.Failing that, look at the output of
mysql_real_escape_string(); it might be appropriate for MS SQL Server too. It depends on how it does the escaping (and what escaping it does).