note 69013 deleted from function.mysql-escape-string by nlopess

From: Date: Tue, 01 May 2007 13:41:36 +0000
Subject: note 69013 deleted from function.mysql-escape-string by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126049@lists.php.net to get a copy of this message
Note Submitter: eth at ethaniel dot com ---- a way to clean _POST _GET and _COOKIE along with their registered global variables. <?php function cleanmysql($arr,$arr2) { foreach ($arr as $gt1=>$gt2) { if (is_array($arr[$gt1])) { list($arr[$gt1],$arr2[$gt1])=cleanmysql($arr[$gt1],$arr2[$gt1]); } else { $gt2=mysql_escape_string($gt2); $arr[$gt1]=$arr2[$gt1]=$gt2; } } return array($arr,$arr2); } list($_GET,$GLOBALS) = cleanmysql($_GET,$GLOBALS); list($_POST,$GLOBALS) = cleanmysql($_POST,$GLOBALS); list($_COOKIE,$GLOBALS) = cleanmysql($_COOKIE,$GLOBALS); ?>

« previous php.notes (#126049) next »