Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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