Re: PHP adding / in front of apostrophes

by "Mike Taylor" <lonewolf(at)one.net>

 Date:  Thu, 5 Sep 2002 02:12:07 -0400
 To:  "HWG - Techniques" <hwg-techniques(at)hwg.org>
 References:  home
  todo: View Thread, Original
As an ASP/SQL guy, this sounds like it was a setting the programmer had
initiated so that the data could be prepared properly before attempting to
insert it into the database.  SQL bombs on apostrophes using INSERT
statements, so programmers either do the double apostrophe trick (change a
single apostrophe to a double apostrophe so that SQL doesn't get confused)
or the apostrophes and quotes are escaped with a backslash.

Apparently PHP has a few functions that enable what's known as "Magic
Quotes."  They are magic, I gather, because once enabled they will
automatically add backslashes to all GET, POST or COOKIE data.  So if you're
adding stuff to the site using an online form and posting it, then all
apostrophes are automatically getting this backslash because the
magic_quotes_gpc function is active in the configuration file (php.ini).
GPC stands for (GET, POST, COOKIE).

And surprise!  This is a feature.... :)

More info can be found at:
http://www.php.net/manual/configuration.php#ini.magic-quotes-gpc

HTH,
Mike

----- Original Message -----
From: "Christie Cooksey" <christie(at)thearmidalemall.com>
To: "HWG - Techniques" <hwg-techniques(at)hwg.org>
Sent: Wednesday, September 04, 2002 6:57 PM
Subject: PHP adding / in front of apostrophes


> I'm entering text for a php/mysql site and no matter what I do I get:
> master/'s
> women/'s
> I don't know anything about php but it looks like it's only adding the /
> after n's and r's.
>
> Right now I'm using &acute; because it looks better than /' but...
> Is there a code I can use for the apostrophe???
>
> Cheers
> Christie Cooksey  :0)
> http://www.thearmidalemall.com
> http://www.designedbychristie.com
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA