note 78753 deleted from function.mysql-real-escape-string by danbrown
| From: | danbrown@php.net | Date: | Sat, 14 Mar 2009 15:05:03 +0000 |
| Subject: | note 78753 deleted from function.mysql-real-escape-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151920@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
// this doesn't do adding the quotes, checking for null, etc that the quote smart does, it
simply sanitizes input and handles arrays recursively
<?php
function sanitize($input){
if(is_array($input)){
foreach($input as $k=>$i){
$output[$k]=sanitize($i);
}
}
else{
if(get_magic_quotes_gpc()){
$input=stripslashes($input);
}
$output=mysql_real_escape_string($input);
}
return $output;
}
?>
// use: if you are going to use $_POST, $_GET, $_COOKIE or $_REQUEST, include the appropriate line
first.
$_POST=sanitize($_POST);
$_GET=sanitize($_GET);
$_COOKIE=sanitize($_COOKIE);
$_REQUEST=sanitize($_REQUEST);