I am having an issue passing a % sign via the $_GET method. I am running the variable through urlencode() before sending it to the browser and it is adding all the + signs between words but it does nothing with the % and this is causing a 404 error. I have also tried using rawurlencode() but it is the same effect with the error. This is an issue for me as I am coding my own forum and I cannot control if a user uses % instead of percent. Can anyone think of why urlencode() is not encoding the % sign?
Here is my code for the url
<a href="reply.php?tid=' . $tid . '&pid=' . $messages['post_id'] . '&body=' . urlencode($messages['message']) . '>Reply & Quote</a>
The posted code does not have a closing double-quote for the HREF value.
Yes, I know I didnt post the code exactly as it is the html is all there and working fine its the urlencode () that isnt working that is why I asked what else I could do because whenever a user puts a % sign into their post it is not encoded with %25 as it should be.
Works fine for me:
C:\Users\xxxxxxx>php -r "echo urlencode('%x%x%');"
ok so it is encoding correctly or so it looks like it when I click the link but for some reason any url with a % in the $_GET variable causing this error:
An appropriate representation of the requested resource /reply.php could not be found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
For some reason it is only urls with a % in the $_GET variable that are causing this error. Do you have any idea what could be causing this?
Perhaps we need to see the actual PHP code in question? Maybe $message is too long for use in a URL?
Originally Posted by NogDog
What is the limit? I read that it is over 2000 characters for the lowest limit. When I checked the number of characters in my url that I was passing it was 299. I posted the php that was being used, here is the message that was in the variable.
"Currently the show only measures contestant's success based on % of total body weight lost. Do you think they should measure total body fat percentage? Voice your opinions here."
Here is the encoded URL:
"http://www.realitytvaddict.com/reply.php?tid=1312&pid=1714&body=Currently+the+show+only+measures+contestant%27s+success+based+on+%2 5+of+total+body+weight+lost.+Do+you+think+they+should+measure+total+body+fat+percentage%3F+Voice+you r+opinions+here."
My suspicion is something in your web server's configuration, perhaps some sort of (misguided?) security setting that does not allow some aspect of that string in a URL? At least, if I send it to a couple other domains, I don't get the "Not acceptable..." error (though of course I get a 404).
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)