...

View Full Version : "&" character in valid HTML



billgates2000
01-23-2007, 10:19 AM
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?

degsy
01-23-2007, 01:41 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum