note 19611 deleted from function.quotemeta by nlopess
| From: | nlopess@php.net | Date: | Fri, 17 Feb 2006 11:15:06 +0000 |
| Subject: | note 19611 deleted from function.quotemeta by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-103901@lists.php.net to get a copy of this message | ||
Note Submitter: jasongodsey at hotmail dot com
----
function cleansql ($text) {
$chars = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY);
$count = count($chars);
for ($c=0; $c<$count; $c++) {
$letter=$chars[$c];
if (!preg_match("/[a-zA-Z0-9]/", $letter)) {
$return .= "\\$letter";
} else {
$return .= "$letter";
}
}
return $return;
}
# I use this so quote just about everything.
# $blah='jason**$_';
# $newblah = cleansql($blah);
# print "$newblah\n";
# returns: jason\*\*\$\_