08-25-2005, 12:23 PM
OK, so the problem wasnt what I thought it was but this is the function
Function CheckString (s, endchar)
s=replace(s, "'", "''")
CheckString="'" & s & "'" & endchar
which should escape all single quotes and then wrap quotes around the whole string ready for insertion in an sql statement.
however I'm having a problem when I insert a blowfish encrypted string into the function, it puts the first quote on the beginning but not at the end (but only sometimes)
08-26-2005, 08:56 PM
what is endchar for?
this is gunna sound stupid but are you sure you arent adding ' to the end and then adding endchar after it so its no longer on the end?
you may also wish to note that if you do not want to alter the value of global s (if there is a global s) you can simply useFunction CheckString(s, endchar)
CheckString = "'" & Replace(s, "'", "''") & "'" & endchar
End Functionfor example if you were using s = CheckString(s, ".") this might mess up a bit
08-27-2005, 09:22 AM
end char is usually a comma the function prepares the string for insertion into a mysql database, so sometimes its a comma sometimes its blank.
In the end I had to use base64 instead of blowfish. I spoke to my boss and he said they never solved the issue when they used it on another site - which would probably explain why I couldnt fix it.
Basically sometimes the encryption would throw out a character that bombed out the sql statement because it would destroy anything on the same line as it, so you would only get half the line and then the code would carry on.
I tried doing a while loop so that the encryption would run again if it had gone funcky but in the code it always came back as having the ', on the end but if you tried to display it or insert it into an aql statement it crapped out.
08-27-2005, 02:39 PM
i have had a problem similar to that kinda before, it just happened when i tried to write binary data that had been adodb.streamed into txt eg when you try and write a charcacter that has an ascii index of less than 32 (eg the backspace character) but this did not matter until i tried to write it out, when it was in the string it was fine but when i tried to write it out it just stopped dead in its tracks and moved on to the next line, maby it just confuses the interpreter :confused: