note 62563 deleted from function.get-magic-quotes-gpc by betz
| From: | betz@php.net | Date: | Sat, 04 Mar 2006 01:17:41 +0000 |
| Subject: | note 62563 deleted from function.get-magic-quotes-gpc by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104799@lists.php.net to get a copy of this message | ||
Note Submitter: acid369 at gmail dot com
Reason: bad code
----
I've wrote a simple function to slash everything submitted via a form which I use a lot,
especially if I'm inserting into MySQL.
<?php
function SlashMagicQuotes(&$Array) {
if (!get_magic_quotes_gpc()) {
foreach ($Array as $ArrayKey => $ArrayValue) {
$Array[$ArrayKey] = addslashes($ArrayValue);
}
}
}
?>
Call with:
<?php SlashMagicQuotes($_POST); ?>
Just replace $_POST with $_GET or $_REQUEST depending on your script, saves having to check
variables individually.