How to escape strings in SQL Server using PHP?

前端 未结 14 1628
我寻月下人不归
我寻月下人不归 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:44

    For the conversion to get the hexadecimal values in SQL back into ASCII, here is the solution I got on this (using the function from user chaos to encode into hexadecimal)

    function hexEncode($data) {
        if(is_numeric($data))
            return $data;
        $unpacked = unpack('H*hex', $data);
        return '0x' . $unpacked['hex'];
    }
    
    function hexDecode($hex) {
        $str = '';
        for ($i=0; $i

提交回复
热议问题