Apostrophe and UPDATE

Paul Foraker paul at whitefeather.com
Wed Oct 9 02:37:50 EDT 2013


While building a LiveCode front end to a MySQL database, I ran into the
apostrophe-in-the-data problem. My friend "O'Byrne" cannot get updated.

For INSERTs, the variable substitution method works great -- I can post
O'Byrne's name as a new record.

But, what should I do about UPDATE ?

Here's my test code:

<code>
on testUpdate
  global gCRMdbID
   put "last_name,notes" into tFields
   put fld "contact_id" into tID
   put fld "last_name" into tLastName
   put fld "notes" into tNotes
   put "UPDATE contact SET (" & tFields & ") VALUES (:1, :2)" & " WHERE
id=" & tID into tSQL
   revExecuteSQL gCRMdbID, tSQL, "tLastName", "tNotes"
   if the result is NOT a number then
   answer error "There was a problem adding the record to the database:" &
cr & the result as sheet
      exit to top
   end if
end testUpdate
</code>

ERROR MESSAGE in the result:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near
'(last_name,notes) VALUES ("O\'Byrne", "betting this won\'t work!") WHERE
id=599' at line 1

Any suggestions?

Thanks,
-- Paul



More information about the Use-livecode mailing list