Re: magic quotes
| From: | Justin French | Date: | Thu, 03 Apr 2003 07:29:46 +0000 |
| Subject: | Re: magic quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142094@lists.php.net to get a copy of this message | ||
Hi Philip,
Thanks for taking the time...
$me = "confused";
...but rather than attempting to get a grip on the past, I need a solution
for the future :)
So,
1. turn ON runtime and gpc
2. only addslashes() when inserting into the database IF
get_magic_quotes_runtime() is 0 (false)
3. only stripslashes() when retrieving from the database IF
get_magic_quotes_runtime() is 0 (false)
Right so far?
Then I need to know how to fix up possible mistakes in the past.
What should I do to the current data in multiple tables which may or may not
have had the addslashes() "done twice". Any one got some cool code???
Justin
on 03/04/03 6:43 PM, Philip Olson (philip@cornado.com) wrote:
> On Thu, 3 Apr 2003, Justin French wrote:
>
>> Hi all,
>>
>> Can I just have a quick head check on magic quotes runtime (&gpc)?
>>
>> I have them both set to Off currently, and my pages work fine. However,
>> when I set them to on, I end up with slashes throughout the mysql data.
>
> This means you essentially ran addslashes() twice before
> insertion. Don't do that. You should never ever have to
> strip slashes from data already in the database.
>
>> Is this the expected behaviour? Seems counter-intuitive to me, but I've
>> never really cared about it 'till today, because i've never had a problem!!
>
> No, only add slashes once. Do this with a function like
> addslashes() OR do it magically. Once.
>
>> What is a common setting for these two directives, so that I can have my LAN
>> server *reasonably* "normal".
>
> Defaults to on so I guess that's "normal". See also
> get_magic_quotes_gpc()...
>
> Regards,
> Philip
>
> ---
> [This E-mail scanned for viruses]
>
>