question about magic quotes

This is a discussion on question about magic quotes within the PHP Language forums, part of the PHP Programming Forums category; Hi all, I've been reading up on magic quotes but I'm still confused, seems like all the info ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-29-2004
Marcus
 
Posts: n/a
Default question about magic quotes

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

Reply With Quote
  #2 (permalink)  
Old 10-29-2004
Marcus
 
Posts: n/a
Default Re: question about magic quotes

Marcus wrote:

> 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
>


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

Reply With Quote
  #3 (permalink)  
Old 11-02-2004
Michael Fesser
 
Posts: n/a
Default Re: question about magic quotes

.oO(Marcus)

>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?


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.

>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?


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

Micha
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:39 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0