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 Quote 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"); Quote 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']); Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/154215-solved-amp-not-showing/#findComment-810775 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.