Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    "&" character in valid HTML

    Hi,

    I have a data-driven website (ASP with mySQL), which I'm trying to make as standard-compliant as possible. I'm having trouble with the ampersand symbol ("&").

    There are thousands of articles in my database, which containg the character "&". And when these articles are displayed on the site, the page generated fails W3C validation.

    What I did was to add a code in my script which generates the page, which replaces the "&" character found in a database article with "&". It's a standard replace command, like replace(rs_record_text, "&", "&"). This works, and generates a valid page. However, in some cases there are some special characters in the recordset text which get messed up. For example, the french character "" gets converted to some weird text, probably because there is an "&" used when that character is stored in the database.

    Is there a way make a valid page with the "&" character in any other way?

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, you need to replace & with &

    You could do this before the insert

    You could create a function to replace special characters with ASCII or HTML Entity values
    http://www.w3schools.com/tags/ref_entities.asp

    Also checkout the Server.HTMLEncode function


  •  

    Posting Permissions

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