简体   繁体   中英

mysqli_real_escape_string($link,$_REQUEST) for all variables

I'm Using Mysqli for the first time .

In mysql i have used this .

$escapedGet = array_map('mysql_real_escape_string', $_REQUEST);
extarct($escapedGet ).

now i have tried a lot for mysqli_real_escape_string with mysqli_real_escape_string($link,$_REQUEST)

it says second parameter should be string , i tried passing it with string with a loop , but can't make it work , can anyone help please .

Thanks in advance

I do that this way:

function sanitize($value){
    global $mysqli;
    return $mysqli->real_escape_string($value);
}

if($_POST){$_POST = array_map('sanitize', $_POST);}
if($_GET){$_GET = array_map('sanitize', $_GET);}
if($_COOKIE){$_COOKIE = array_map('sanitize', $_COOKIE);}
if($_REQUEST){$_REQUEST = array_map('sanitize', $_REQUEST);}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM