[Gambas-user] MySQL query problems with apostropies

Keith Clark keithclark at ...2185...
Wed Apr 7 21:33:12 CEST 2010


On Tue, 2010-04-06 at 16:27 -0500, nando wrote:
> Strings that contain these three characters: quote, double quote and backslash
> need to be escaped.
> You escape them by having a backslash immediately before it.
> Example:
>  Patty O'Lantern  would be...
>  Patty O\'Lantern
> 
> One way is to make a small function that will insert a backslash
> when it finds a quote or double quote or backslash. 
> 
> When you create your SQL string (Insert, Update, Select, etc)
> you escape the strings for the char, varchar, text, or similar.
> 
> sql = "SELECT * FROM inventory WHERE part = ' & escape(mypart) & "';"
> 
> SELECT from the database will not return the 'escape' backslash.
> It will appear normal.
> 
> Please note: / (on the question mark key) is not the backslash.
> \ is the backslash.
> 
> -Fernando
> 
Can I not do this with Replace$?  I can with the single quote with
Replace$($string,"'","\'"), but I cannot do the same with double quotes.

I'm not sure I understand this whole escape thing.






More information about the User mailing list