How to escape strings in SQL Server using PHP?

前端 未结 14 1481
我寻月下人不归
我寻月下人不归 2020-11-22 09:36

I\'m looking for the alternative of mysql_real_escape_string() for SQL Server. Is addslashes() my best option or there is another alternative funct

14条回答
  •  情歌与酒
    2020-11-22 09:50

    Another way to handle single and double quotes is:

    function mssql_escape($str)
    {
        if(get_magic_quotes_gpc())
        {
            $str = stripslashes($str);
        }
        return str_replace("'", "''", $str);
    }
    

提交回复
热议问题