Apostrophes in URLs

Results 1 to 4 of 4

Thread: Apostrophes in URLs

  1. #1
    Shawn Kubik Guest

    Default Apostrophes in URLs

    I&#039;m having to fix a bug on my project that involves the use of apostrophes. I&#039;ve read the FAQ on aspfaqs.com about getting SQL to accept apostrophes in keywords and such, and that problem has been fixed. However, I have another problem that I&#039;m not sure how to fix. When I navigate from page to page, I pass the keywords that were entered by the user along with it... in the URL.<BR><BR>So, for example, on the search results page, each result is a link, but the URL of that link contains a keywords argument.. so if the user searches for the name "O&#039;Brien", the link for the search result would be something like: <BR>&#060;A HREF="http://localhost/clientDetails.asp?client_id=2&keywords=O&#039;Brie n"&#062;James O&#039;Brien&#060;/A&#062;<BR><BR>While this is all well and good, the page is giving an error:<BR>"Expected &#039;;&#039;"<BR><BR>In all honesty, it looks like it all actually works, but I hate having that error... any ideas of how to get rid of it?<BR><BR>Thanks,<BR><BR>- Shawn Kubik.

  2. #2
    Join Date
    Dec 1969

    Default Server.URLEncode...

    ...or the escape function in client-side JavaScript.<BR><BR>Look in the ASP docs for the built-in Server object and the URLEncode method it supports. Or if you are building the URL from client-side JS, look at the escape function that it has built-in.<BR><BR>

  3. #3
    Liesbeth Guest

    Default RE: Apostrophes in URLs

    Maybe you can replace the apostrophes by "& followed by #39;"

  4. #4
    Join Date
    Dec 1969

    Default Do *NOT* listen to that answer!

    If you did that, you&#039;d just get in more trouble! Because the & character has special significance in a URL and cannot be use that way. This person is VERY badly confused...confusing URLs with HTML.<BR><BR>Actually, an apostrophe in a URL would be represented as %27 (that&#039;s the percent sign followed by the two digit *hexadecimal* representation of the ASCII for the &#039; mark). But do NOT do this. Do yourself a favor and use Server.URLEncode or the JS function named "escape".

Posting Permissions

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