I’m in trouble because the method I use to encode a query string works on one remote server but not on another at the same ISP. I don’t understand why, but I need to resolve it.
On one site the query string is encoded once, and remains fixed. On the other it is repeatedly encoded, so it ‘grows’. e.g. ‘[’ first becomes ‘%5B’ then ‘%255B’, then ‘%25255B’ and so on. When the string is recovered from the SESSION and used to repeat the search, the result is rubbish, of course.
An obvious reason for this to happen would be if the uploaded files were different. I’ve checked this many times.
Before I dive into code, can anyone tell me if it’s actually possible for ‘php.ini’ or other server settings to affect the way ‘htmlentities’ and similar functions work. I would not have thought so, yet that’s what appears to be happening in this case.
Thank you. I think that will be helpful shortly. I’ve decided the only thing to do is to build myself a simple test script, shorn of all the complicating calls to MySQL and images, etc. Then I can try out all manner of methods in parallel, and see which produces the most consistent results.
Thank you. Yes, $_SERVER[‘QUERY_STRING’] does contain what I want,
“et%5B0%5D=ALL&loc%5B14%5D=SW&save=eatg&eatg=Search”
and I can save it to the SESSION.
My question was aimed at finding out how to retrieve it from the session into a variable called (for example) $get, and decode it so it can be added to a ‘Location’ statement as in:-
I’ve tried several ways, not all successful, with various combinations of ‘urldecode’, ‘html_entity_decode’ etc.
Even stranger I found one way that worked fine on one web site but not at another hosted at the same ISP. In that case the ‘%’ were being repeatedly re-coded, so for example the ‘[’ of the query grew from ‘%5B’ to ‘%255B’ then to ‘%25255B’ with each iteration. I could find no difference in the PHP scripts, so tentatively conclude that the PHP environments must be different, but could this really be so ?
Perhaps it would be wise to use a loop to repeatedly decode any stored query variable to ensure there are no entities left before use ?
You shouldn’t be using html entities to begin with. The solution is really really easy. Do not encode the query string at all until output. Just store it raw in the session array.
which is a nightmare ! No doubt PHP thinks the query string is an array in it’s own right. How would I go about converting that back to a string in a variable ‘$get’ that I could use in:-
header("Location: /?$get");
My problem remains that what’s working on one site isn’t working on another at the same ISP and probably on the same server, and the difference lies in the repeated encoding of the SESSION variables.