Re: Problem with apostrophes!!
| From: | Gfunk | Date: | Tue, 13 Mar 2001 03:36:26 +0000 |
| Subject: | Re: Problem with apostrophes!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43607@lists.php.net to get a copy of this message | ||
In mysql you can either enclose the string in double quotes, ie:
"ken's \"trucks\" aren't as good as bob's"
or you use the backslash:
'ken\'s "trucks" aren\'t as good as bob\'s'
either way, you'll be using the backslash for one or the other quote. pretty
sure mysql doesn't support the standard SQL '' inside single quoted strings
like
oracle/sybase/mssql/whatever
Gfunk
----- Original Message -----
From: "Reuben D Budiardja" <reubendb@goshen.edu>
To: "Kenneth R Zink II" <Hellcat1@EV1.Net>; "PHP"
<php-general@lists.php.net>
Sent: Tuesday, March 13, 2001 2:32 PM
Subject: Re: [PHP] Problem with apostrophes!!
>
> Maybe you can use this function. I don't use MySQL, I use Oracle, and I
> build this function for Oracle, but I think the basic problem (and
solution
> is the same). I think basically you need to escape ' by adding another '.
> Thus "Ken's" should become "Ken''s".
>
> function format_mysql_string($string)
> {
> $string = StripSlashes($string);
> $string = ereg_replace("'", "''", $string);
> return $string;
> }
>
> Reuben D. Budiardja
>
> At 09:19 PM 3/12/01 -0600, Kenneth R Zink II wrote:
> >My MySQL insert statements is returning errors when a field has an
> >apostrophe in it. (I.E. Ken's) is there a way to get around that without
> >using the \ in front of the apostrophes??
> >
> >I've never had this problem before, in the past (on different servers)
when
> >a variable is inserted, it just accepted it.
> >
> >Help!! I need to know A.S.A.P.
> >
> >Kenneth R Zink II Hellcat1@S-Series.Org ICQ# 5095094
> >'87 GMC S-15 Ext. Cab (Hurricane) ...BBC 524 being built !!!
> >http://www.s-series.org/htm/windstorm/project-windstorm.htm
> >'85 Chevy S-10 Blazer (FireStorm) ...Soon to be 3.4L SFI !!!
> >http://www.s-series.org/htm/firestorm/firestorm.htm
> >'84 Oldsmobile Delta 88 Delta 88 Royal Brougham.
> >Racing by the grace of God!!!
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-general-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>