jeffkas Posted January 30, 2011 Share Posted January 30, 2011 I am storing thousands of titles in mysql and many of these have a title with an ampersand. An example is how AT&T is getting stored in the database: at-amp-t Easy enough, I thought.. I'll just run str_replace on it before I save it to the database. $title = str_replace("-amp-", "&", $title); That works great.. except when I click the new hyperlink created from this url. It looks correct... showing the exact url of what is stored in mysql: (http://www.domain.com/this-is-the-at&t-title) ...but no url with this ampersand works. All other $title urls works great. If I don't run str_replace on it, it works fine.. but then I get a url stored as at-amp-t... which I'm trying to avoid. Thoughts? Link to comment https://forums.phpfreaks.com/topic/226143-passing-an-ampersand-in-a-url/ Share on other sites More sharing options...
KevinM1 Posted January 30, 2011 Share Posted January 30, 2011 Take a look at urlencode and urldecode, or htmlentities Link to comment https://forums.phpfreaks.com/topic/226143-passing-an-ampersand-in-a-url/#findComment-1167416 Share on other sites More sharing options...
btherl Posted January 31, 2011 Share Posted January 31, 2011 Are you able to look in the HTML source of a page that links to the at&t url and see what it is doing? You need to whatever it is doing. Usually people don't use an "&" in the path component of a url, but if you wanted to do it I think you would encode it using urlencode(). htmlentities() is for displaying things in HTML, not for urls. Link to comment https://forums.phpfreaks.com/topic/226143-passing-an-ampersand-in-a-url/#findComment-1167561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.