Connecting Tech Pros Worldwide Help | Site Map

question about magic quotes

  #1  
Old July 17th, 2005, 10:21 AM
Marcus
Guest
 
Posts: n/a
Hi all,

I've been reading up on magic quotes but I'm still confused, seems like
all the info I can find is just regurgitating the little blurb in the
php manual. My question is this: if I turn both magic_quotes_gpc and
magic_quotes_runtime ON in php.ini, does that mean I do not need to also
use addslashes() and stripslashes() on all my GPC and MySQL data? i.e.
does magic_quotes in effect take care of addslashes() and stripslashes()
automatically? Thanks in advance.

Marcus

  #2  
Old July 17th, 2005, 10:21 AM
Marcus
Guest
 
Posts: n/a

re: question about magic quotes


Marcus wrote:
[color=blue]
> Hi all,
>
> I've been reading up on magic quotes but I'm still confused, seems like
> all the info I can find is just regurgitating the little blurb in the
> php manual. My question is this: if I turn both magic_quotes_gpc and
> magic_quotes_runtime ON in php.ini, does that mean I do not need to also
> use addslashes() and stripslashes() on all my GPC and MySQL data? i.e.
> does magic_quotes in effect take care of addslashes() and stripslashes()
> automatically? Thanks in advance.
>
> Marcus
>[/color]

Sorry for another post, but just to clarify on my previous post, is
there a proper configuration with any/all of the magic_quotes values so
that I can "safely" accept data and interact with my DB without using
addslashes/deleteslashes everywhere?

Also, when I look in my MySQL tables through the command prompt, if
records with single quotes do not show up as escaped by /, am I doing
something wrong? Thanks again.

Marcus

  #3  
Old July 17th, 2005, 10:24 AM
Michael Fesser
Guest
 
Posts: n/a

re: question about magic quotes


.oO(Marcus)
[color=blue]
>Sorry for another post, but just to clarify on my previous post, is
>there a proper configuration with any/all of the magic_quotes values so
>that I can "safely" accept data and interact with my DB without using
>addslashes/deleteslashes everywhere?[/color]

I don't care about magic quotes anymore, I do the escaping on my own.
When "importing" user-submitted data I run it through something like
this to have the data in raw format:

function filter($data) {
return get_magic_quotes_gpc() ? stripslashes($data) : $data;
}

Then, when necessary, I use mysql_escape_string(), htmlspeciclchars()
etc. to escape/convert the data, dependent on what I wanna do with it.
IMHO it's more reliable to have control over the data handling instead
of relying on some "background magic", which might lead to unexpected
results.
[color=blue]
>Also, when I look in my MySQL tables through the command prompt, if
>records with single quotes do not show up as escaped by /, am I doing
>something wrong?[/color]

No, the escape chars are not stored in the database.

Micha
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about validation and sql injection Sudhakar answers 2 June 2nd, 2008 11:36 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 5 November 14th, 2005 12:36 PM
mysql_real_escape_string() vs addslashes() Marcus answers 2 November 3rd, 2005 03:05 PM
Session and Magic Quotes Xizor answers 0 July 16th, 2005 11:48 PM