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" <[EMAIL PROTECTED]>
To: "Kenneth R Zink II" <[EMAIL PROTECTED]>; "PHP"
<[EMAIL PROTECTED]>
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     [EMAIL PROTECTED]    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: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to