aksdesigns Posted November 20, 2009 Share Posted November 20, 2009 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?? Quote Link to comment https://forums.phpfreaks.com/topic/182276-remove-single-quotation-marks-on-db-item/ Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2009 Share Posted November 20, 2009 you could use the addslashes php function Quote Link to comment https://forums.phpfreaks.com/topic/182276-remove-single-quotation-marks-on-db-item/#findComment-961828 Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2009 Share Posted November 20, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/182276-remove-single-quotation-marks-on-db-item/#findComment-961874 Share on other sites More sharing options...
aksdesigns Posted November 20, 2009 Author Share Posted November 20, 2009 Thanks for the help. 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. Thank youuu. Quote Link to comment https://forums.phpfreaks.com/topic/182276-remove-single-quotation-marks-on-db-item/#findComment-961911 Share on other sites More sharing options...
megaresp Posted November 20, 2009 Share Posted November 20, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/182276-remove-single-quotation-marks-on-db-item/#findComment-961919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.