timmah1 Posted April 15, 2009 Share Posted April 15, 2009 In my database, I have a name Health & Beauty When this is pulled out of the database, I replace the spaces with - so I can use it in the url I then want to display that name on the page, but the problem I'm having is the & So this is what I've done, but no matter what I do, the only thing that shows is Health, it won't the & Beauty part. $cat = ":" . str_replace('-', ' ', $_GET['name']); $cat1 = ":" . str_replace('&', '&', $cat); echo $cat1; Can anybody show me what I'm doing wrong? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/154215-solved-amp-not-showing/ Share on other sites More sharing options...
laffin Posted April 15, 2009 Share Posted April 15, 2009 why the colons? it might be easier to use urlencode <?php echo urlencode("Health & Beauty"); Link to comment https://forums.phpfreaks.com/topic/154215-solved-amp-not-showing/#findComment-810746 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 You cannot pass & through the url as a string as it is a parameter separator. You should encode the string with urlencode() and then decode with urldecode(). <a href="xyz.php?name=".urlencode($name).""> // receiving page print urldecode($_GET['name']); Link to comment https://forums.phpfreaks.com/topic/154215-solved-amp-not-showing/#findComment-810751 Share on other sites More sharing options...
timmah1 Posted April 15, 2009 Author Share Posted April 15, 2009 Thank you. Works now Link to comment https://forums.phpfreaks.com/topic/154215-solved-amp-not-showing/#findComment-810775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.