Jump to content

Recommended Posts

Hey guys.

 

On this page:

http://megalyrics.net/view-442707-pink_centerfold.html

 

The alt for the album cover and the link title for the three links below it don;t show correctly. This is because there's a ' (single quotation mark) in the title of the album i'm calling the text for.

 

The code i use for the links is:

 

echo "<tr><td align='right' class='buylink'><br class='smallBr'><a href='http://www.amazon.com/s/?tag=meglyr-20&creative=392013&campaign=212361&link_code=wsw&_encoding=UTF-8&search-alias=aps&field-keywords=".$artist."&Submit.x=0&Submit.y=0&Submit=Go' target='_blank' class='buylink' title='Buy ".$album." album from Amazon'>Buy from Amazon</a><br class='smallBr'><hr class='top-hr' align='right'><a href='http://www.cduniverse.com/sresult.asp?HT_Search_Info=".$artist."&HT_Search=Artist&GO.x=4&GO.y=11&GO=Go+Find+It!&frm=lk_megalyr' title='Buy ".$album." album from CD Universe'>Buy from CD Universe</a><br class='smallBr'><hr class='top-hr' align='right'><a href='http://clkuk.tradedoubler.com/click?p(54791)a(1741055)g(16700006)' title='Buy ".$artist." posters'>Buy ".$artist." posters</a><br/><br/><br/></td></tr>";

 

Does anyone know how i can remove any punctuation that may be in an album title to stop it messing up the output HTML??

 

 

You need to use htmlentities (with the second parameter set to ENT_QUOTES) on all content/data that you output on a web page to prevent any special HTML characters (such as <, >, ', "...) in it from breaking the HTML syntax on your page.

 

And, if you are putting any special characters in to a URL, you need to use urlencode

Bit of a novice PHP coder. I don;t have a clue how i'd implement what you've both just said :) Any guidance would be muchly appreciated.

 

Take a look at the html_entities page in the online PHP Manual. Scroll down the page to see many examples.

 

Also, note the handy 'See Also' box. This gives you links to related functions, making it easy to find something that might do a better job for a specific situation.

 

I find the best way of getting access to the info in the online PHP Manual is actually via Google. For example, entering: php html_entities

 

...brought up the correct page immediately. This makes it easy to find PHP info right from my browser. Very handy.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.