note 47888 deleted from function.mysql-escape-string by tomsommer

From: Date: Fri, 03 Dec 2004 23:46:47 +0000
Subject: note 47888 deleted from function.mysql-escape-string by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81346@lists.php.net to get a copy of this message
Note Submitter: hexa of h3xa dot com ---- i´ve come with this handy function to apply to variables (if an array, non multi-dimesional only) everytime i need to insert them in the db. it checks if magic_quotes are enabled, to not re-add slashes. <?php function slashes(&$var) { if (is_array($var)) { if (!get_magic_quotes_gpc()) { foreach ($var as $chave => $valor) { $var[$chave] = mysql_escape_string($valor); } } } else { mysql_escape_string($var); } return true; } ?> example: slashes($_POST); mysql_query(...);

« previous php.notes (#81346) next »