SQL Query error when a String has double quote

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
LXS98
Posts: 6
Joined: Tue Apr 02, 2024 7:09 am

SQL Query error when a String has double quote

Post by LXS98 » Fri Apr 26, 2024 5:43 am

Hi, I need help. I tried to pass a string to a URL parameter for my web service, however, it says that there's an error on the SQL Syntax.
I suspect this is because on my string that has a "double quote" value.

Example: Jhon's Madul"a

Anyone know how to handle this on LiveCode to prevent error on the SQL Syntax?

Thanks a lot.

stam
Posts: 2692
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: SQL Query error when a String has double quote

Post by stam » Fri Apr 26, 2024 6:19 am

Please post the code that is causing the error… more than likely this will be a simple fix.

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 136
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: SQL Query error when a String has double quote

Post by paul@researchware.com » Fri Apr 26, 2024 3:48 pm

There is a set of characters that need to be 'escaped' for mySQL. I can't find my code that I use for this, but things like cr, slash, quote, etc. I generalky use the "regex" or C-string model of escaped characters for mySQL, so cr becomes /n, slash becomes //, etc. If you are unfamilar with these you can look up mySQL reserved characters to see what they should be.
Paul Dupuis
Researchware, Inc.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9679
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: SQL Query error when a String has double quote

Post by dunbarx » Fri Apr 26, 2024 5:31 pm

Paul and Stam are trying to convince you to solve your problem like an adult would.

But I ran into something like this many years ago, and solved it like a petulant child. I substituted ASCII 210 (or 211, I cannot now remember) for every quote constant at risk:

Code: Select all

replace quote with numToChar(210) in yourProblemSnippet
Looks the same, and those arcane chars do not likely require escapement.

Craig

Post Reply

Return to “Windows”