buckibooster Posted March 24, 2014 Share Posted March 24, 2014 (edited) 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 March 24, 2014 by buckibooster Link to comment Share on other sites More sharing options...
Ingolme Posted March 24, 2014 Share Posted March 24, 2014 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 More sharing options...
justsomeguy Posted March 24, 2014 Share Posted March 24, 2014 Special characters in a URL include anything that has meaning, like ?, &, =, /, #, etc. All of them need to be escaped if they are part of data in the URL instead of part of the actual URL. Link to comment Share on other sites More sharing options...
buckibooster Posted March 25, 2014 Author Share Posted March 25, 2014 Thank you Ingolme! I believe that your solution will work for me. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now