Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com

Register for 360Flex in DC using the ad below and you will automatically be entered in a drawing for a free ticket. Read more.
place your ad here

Web Premium





Escaping apostrophies in AIR / SQLite

November 18th, 2008 . by polygeek

I ran into a problem with AIR SQLite where a user is allowed to enter text that is saved to the database. If they add an apostrophe to the text then the SQL query will fail silently.

All it takes to fix the problem is replace each apostrophe with two apostrophes. It must be something to do with the old Buddhist saying, “One apostrophe makes a bug. Two apostrophes make one apostrophe.”

Here’s the code:

var textThatMayHaveApostrophe:String = someInput.text;
var regEx:RegExp = /'/g; //'
textThatMayHaveApostrophe = textThatMayHaveApostrophe.replace( regEx, "''" );

The //’ comment following the RegEx declaration is there so that Flex Builder will apply code coloring correctly below that line. Otherwise it thinks everything below that line is part of a String. Even though it still compiles just fine.

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts
    None Found

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud