Apostrophe and UPDATE

stephen barncard stephenREVOLUTION2 at barncard.com
Wed Oct 9 08:44:56 CEST 2013


http://stackoverflow.com/questions/9596652/how-to-escape-apostrophe-in-mysql


On Tue, Oct 8, 2013 at 11:37 PM, Paul Foraker <paul at whitefeather.com> wrote:

> 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
> _______________________________________________
> 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
>



-- 



Stephen Barncard
San Francisco Ca. USA

more about sqb  <http://www.google.com/profiles/sbarncar>


More information about the use-livecode mailing list