Problem with Apostrophe
I am having weird trouble with READING data from my Access database where the field has an apostrophe - but only when I display the field in a textbox.
For example, the field "Don't do this" becomes "Don" when my SQL query outputs the result:
response.write "<input type='hidden' name='campaignid1' value='" & campaignID & "'>"
If I output to regular HTML (e.g. in a <P> tag), the field displays correcly.
Has anyone ever encountered this problem?
response.write "<input type='hidden' name='campaignid1' value='" & server.htmlencode(campaignID) & "'>"
That doesn't seem to do anything... this is really weird.
It's because the parameters for the form field are using apostrophe, so when the apostrophe in the data appears, it's ending the data for that parameter. You need to either escape the apostrophes, or use double quotes for the parameters and escape the double quotes.
Originally Posted by akay
PS. Now that I think of it, instead of using response.write, close the ASP code and use <%= <data> %> to display the data.
response.write "<input type=""hidden"" name=""campaignid1"" value=""" & campaignID & """>"
Those single quotes definitely ****ed everything up... i'm glad that's fixed!
Glad I could help. Usually I'm here ASKING questions. It's nice to be able to give back.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)