Jump to content

[SOLVED] & not showing


timmah1

Recommended Posts

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

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']);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.