Jump to content

Display ampersand hex code from url in html


sixseven

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.

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.