www.webdeveloper.com
Results 1 to 6 of 6

Thread: Problem with Apostrophe

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Cleveland, OH
    Posts
    30

    Exclamation 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?

  2. #2
    Join Date
    Jul 2004
    Posts
    300
    try this:
    Code:
    response.write "<input type='hidden' name='campaignid1' value='" & server.htmlencode(campaignID) & "'>"

  3. #3
    Join Date
    Aug 2006
    Location
    Cleveland, OH
    Posts
    30
    That doesn't seem to do anything... this is really weird.

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Quote Originally Posted by akay
    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.

    ^_^

    PS. Now that I think of it, instead of using response.write, close the ASP code and use <%= <data> %> to display the data.

  5. #5
    Join Date
    Aug 2006
    Location
    Cleveland, OH
    Posts
    30
    This worked!

    response.write "<input type=""hidden"" name=""campaignid1"" value=""" & campaignID & """>"

    Those single quotes definitely ****ed everything up... i'm glad that's fixed!

  6. #6
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Glad I could help. Usually I'm here ASKING questions. It's nice to be able to give back.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles