Jump to content

Recommended Posts

Hello,

 

I'm pretty new to php and have a small problem I can't figure out.

 

I have passed some copy (john & mary) from a small form to a url with php (i used urlencode). The code in the url looks like this john+%26+mary.

 

My problem is, how do I display the %26 as an actual ampersand (&) on the html page? Here is the snippet of code that I am currently using to display the names.

 

<?php echo htmlentities($_GET['gallery']); ?>

 

I have searched and searched and can't find anything to figure this out.

 

Any help would be great.

 

Thanks.

Usually you don't need to urldecode a $_GET value.  Try viewing the source of the page and see what you are getting.  You should see "&" in the source.  If you don't, post what you see here as well as the code that generates it, and we can probably tell you where the encoding is going wrong.  Also it would be good if you print out the original value from $_GET as well.

It looks like with a little messing around from what all of you posted, I fixed the problem. There was another spot that I missed that was passing url info. I took off the urldecode on the GET value and urlencoded another and I'm set. I now have a much better understanding of encode and decode.

 

Thanks for all of the help.

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.