Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meta description " issue

Status
Not open for further replies.

mcode12

Programmer
Aug 8, 2007
25
GB
In my meta description sometime the " is being insert from the database. This is causing problem as it's truncating the meta too early.

Any ideas how to stop this?
 
replace(rs("field"),""","")

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
I want to keep the " not replace it so that the meta description reads 23" television set
 
replace(rs("field"),""","""")

^ replace a single double quote with two of them.

or put the meta desc attributes in single quotes

<META NAME='Description' CONTENT='<%=rs("field")%>.'>

but then you'll have the same issue with single quotes (i.e. if the description has Bob's one stop shop for tv sets)





TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
content="<%=HTMLEncode(RS(Field))%>"

will fix all the quotes into html tag friendly

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
content="<%=HTMLEncode(RS(Field))%>"

Does that need to be Server.HTMLEncode?

Also, that will make you meta tag read as:

21&quot; Television.

Which if it were a webapage would be find but I don't know about using special character codes as values for attributes.

Drex -didn't even know about HTMLEncode, thanks for the tip - had to google it to find the syntax check 'tho



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Server. can usually be ommited in most cases.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
this will also work too, even though it's intended for SQL statements it'll help with most any text qualified value, including propterties of tags:

Code:
Function SQLQuotes(inputString) [green]'Handles the sql string quotes both single and double.[/green]
    If NOT isNull(inputString) Then
        SQLQuotes = Replace(Replace(inputString,"'","''"),Chr(34),Chr(34)&chr(34))
    Else
        SQLQuotes = ""
    end if
End Function

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
I checked on amazon, they do a replace with &quot; and it seems to display fine in Google so I guess that's the root to go.
 
[afro]

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top