replacing apostrophes

M

middletree

I put in some code to keep apostrophes from being a problem. However, on the
display page, they have double quotes. What am I doing wrong?

Here is the code on the page which captures the data from the form, right
before it gets entered into the database:
 
R

Ray at

You should use functions for passing data into a database and pulling it
out. Maybe something along the lines of:

You don't want to actually store "<br>" in your database. Also, in the
SafeOut, you may also want to replace " with &quot;.

''For going in:
strInternalDesc = SafeIn(Request.Form("InternalDesc"))
''code to instert into database

For coming out:
Response.Write
SafeOut(Recordset.Fields.Item("ColumnThatContainsThatValue").Value



Function SafeIn(theString)
SafeIn = Replace(theString, "'", "''")
End Function

Function SafeOut(theString)
SafeOut = Replace(theString, vbCrLf, "<br>")
End Function

Ray at work



middletree said:
I put in some code to keep apostrophes from being a problem. However, on the
display page, they have double quotes. What am I doing wrong?

Here is the code on the page which captures the data from the form, right
before it gets entered into the database:
 
M

middletree

Ok, I can try this. I dont' really understand the difference, though.

Also, can I add the Trim function to the SafeIn function?
 
R

Ray at

middletree said:
Ok, I can try this. I dont' really understand the difference, though.


Well, were you doing that replacing when you were inserting the value into
the database or pulling it out? Normally, you'd replace ' when inserting
and replace vbCrLfs when pulling out. You're doing both, which is out of
the ordinary.


Also, can I add the Trim function to the SafeIn function?

Sure.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top