note 93512 deleted from function.mysql-real-escape-string by danbrown
| From: | danbrown@php.net | Date: | Mon, 14 Sep 2009 17:00:38 +0000 |
| Subject: | note 93512 deleted from function.mysql-real-escape-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160559@lists.php.net to get a copy of this message | ||
Note Submitter: gaurav dot v dot sharma at gmail dot com
----
I solved my problem by writing a small function like this :-)
function filterText($value)
{
if( is_array($value) )
{
$value = array_map('filterText', $value);
}
else
{
$value = strip_tags($value);
$value = trim($value);
if(!get_magic_quotes_gpc())
$value = mysql_real_escape_string($value);
else
$value = mysql_real_escape_string(stripslashes($value));
}
return $value;
}
and calling it as follows
$_POST = filterText($_POST);
This makes sure that the data is still escaped if magic quotes is on or off.