On-Rev: irev to mysql to html charset (apostrophes, etc.) confusion?

Kee Nethery kee at kagi.com
Mon Oct 3 20:49:29 EDT 2011

In Sybase and in Python, if you enclose your text statements in double quotes, you must escape double quotes inside the text string and don't have to escape single quotes. Similarly, if you enclose using single quotes, you must escape the single quotes inside the text string and don't have to escape double quotes. 

select "He's a ""big deal""" <-- will work fine
select 'He''s a "big deal"' <-- will work fine
select "He's a "big deal"" <-- will not work because the double quotes in the text are not escaped
select 'He's a "big deal"' <-- will not work because the single quote in the text is not escaped

I always use single quotes to enclose text and have a routine that escapes them for me

function escapeQuote theText
  if "'" is in theText then
    repeat with x = the number of chars in theText down to 1
      if char x of theText = "'" then
        put "'" before char x of theText
      end if
    end repeat
  end if
  return theText
end escapeQuote

Kee Nethery

On Oct 3, 2011, at 5:02 PM, Pete wrote:

> In SQLite, the way to escape an apostrophe is to precede it with another
> apostrophe, not a backslash.  mySQL allows either method, not sure about
> other SQL implementations.
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> On Mon, Oct 3, 2011 at 10:40 AM, Pierre Sahores <sc at sahores-conseil.com>wrote:
>> Le 3 oct. 2011 à 18:42, Bob Sneidar a écrit :
>>> How are you escaping your sql?
>> If not, it needed where "it's needed" becomes "it\'s needed" to be stored
>> in your SQL backend.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

More information about the Use-livecode mailing list