Re: Help:escape_string and stripslashes
| From: | Jordi Canals | Date: | Sun, 07 Nov 2004 12:46:43 +0000 |
| Subject: | Re: Help:escape_string and stripslashes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201420@lists.php.net to get a copy of this message | ||
On Sun, 7 Nov 2004 03:52:28 -0800 (PST), Stuart Felenstein
<stuart4m@yahoo.com> wrote:
> I asked a question yesterday about this but I think my
> question is now more fine tuned:
>
> Right now I have about 50+ session variables that will
> be inserted into my mysql database in a transaction.
> I need to do the mysql_real_escape_string and because
> magic_quotes_gpc is turned on stripslashes as well.
>
> I'm wondering if there is a way to use a function or
> class within my connection script to take care of all
> of this ? As oppposed to listing everyone out ? I
> know I can pass all the variables as an array but some
> of the variabls are arrays themselves, so not sure how
> that would work.
>
In the manual http://es2.php.net/manual/en/function.get-magic-quotes-gpc.php
you have an example just for that. Take a look to the Example 2.
The way I do it, is using that function, but think the example in the
manual is much better:
function array_deslash(&$array) {
foreach ($array as $key => $value) {
if (is_string($value)) {
$array[$key] = stripslashes($value);
} elseif (is_array($value)) {
array_deslash($arrau[$key]);
}
}
}
Hope this helps,
Jordi.