Jump to content

Passing a String Containing a "#"


buckibooster

Recommended Posts

Why is it that when I call a php page and pass a number of variables to it, one of which contains the "#," that it truncates the string and does not pass any of the variables that follow?

 

For example: http://www.anysite.com/run.php?age='7'&Processed='No'&Description='20140323 Test Proposal #2'&Division='CC57'

 

This call transmits everything until it gets to the "#" sign and stops. The string of passed variables always stops at the "#" character and does not include it. When I remove the "#" character from the passed string, however, everything works just fine. Are there any other characters that must be avoided?

Edited by buckibooster
Link to comment
Share on other sites

If you're generating the URL with PHP, use urlencode(). If you're using Javascript, use encodeURIComponent() on each value before putting them in the query string. If you're manually writing this, substitute for character for the hexadecimal ASCII equivalent with a % symbol. For example # to %23 and ' to %27.

 

I don't think you should have the ' characters in your query because they'll show up in the value when PHP reads it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...