Page 1 of 1
SQL Query error when a String has double quote
Posted: Fri Apr 26, 2024 5:43 am
by LXS98
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.
Re: SQL Query error when a String has double quote
Posted: Fri Apr 26, 2024 6:19 am
by stam
Please post the code that is causing the error… more than likely this will be a simple fix.
Re: SQL Query error when a String has double quote
Posted: Fri Apr 26, 2024 3:48 pm
by paul@researchware.com
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.
Re: SQL Query error when a String has double quote
Posted: Fri Apr 26, 2024 5:31 pm
by dunbarx
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