how to get encrypted string into database

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

how to get encrypted string into database

Post by sphere » Sat Dec 26, 2015 2:04 pm

Hello,

i'm trying to send a encrypted string to my localhost database. The column in the table of course is a varbinary.
But this has some issues because it sees the string as a failure. its aes128 encrypted. encrypting and decrypting in the stack works ok.

Has anyone used mysql_real_escape_string like they use in php/mysql scripts? see https://secure.php.net/mysql_real_escape_string
It seems that using this would solve the problem, but is it usable in livecode?

i already used the info mentioned here: http://lessons.livecode.com/m/4071/l/70 ... l-database before so that's working ok.
Just the encrypted string gives some troubles.

Does anyone know how to get mysql_real_escape_string correct in this line:
put "INSERT INTO " & tTableName & " (" & tFields & ") VALUES (;1, :2)" into tSQL

many thanks for any help on this.
Sphere

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: how to get encrypted string into database

Post by ghettocottage » Sat Dec 26, 2015 5:09 pm

Do you know what characters are causing your problem? If so, you could just write your own function to escape certain characters.

I had some issue once where quotes were causing some problems in my sql, so I did this function:

Code: Select all

--this function escapes quotes out of strings to go to database.
function quoteEncode pString
   put pString into tEncoded
   replace quote with "\" & quote in tEncoded
   replace CR with "\n" in tEncoded

   return tEncoded
end quoteEncode
and then use it like this:

Code: Select all

--get your note and and encode it
   put fld "note" into tNote
   put quoteEncode(tNote) into tNote

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: how to get encrypted string into database(solved)

Post by sphere » Sun Dec 27, 2015 1:32 pm

Thanks ghettocottage for your reply,

maybe i can use that, but i don't know which character would cause the problem.

There are some strange ones used, but i can try your suggestion and see what it does.

this is the message i'm getting
error.JPG

****edit*** looking closely to the error message i saw the fault which slips in easy, before the 1 there you see ; and this should be : :oops:
(solved)
Thanks!

Post Reply

Return to “Databases”