By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

URL GET data problem

P: n/a
Hi...

I have the following chunk of html output by my PHP script:
<select id="show_page" name="show_page">
<option value="3&year=2002&month=10">October 2002</option>
<option value="3&year=2003&month=10">October 2003</option>
<option value="3&year=2003&month=11">November 2003</option>
<option value="3&year=2003&month=12">December 2003</option>
</select>

But when I select one of these from the list and click submit, instead of
appearing like this in the address bar:

http://www.mysite.com/main.php?show_...=2002&month=10

It appears like this instead:

http://www.mysite.com/main.php?show_...3%26month%3D10

You can see the & and = characters have been substituted for the URL-safe
equivalents. I'm sure it's PHP doing this, as I have a 99% identical page in
ASP which works fine. Is there an option I can switch to stop it
translating?

TIA,

Plankmeister
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I noticed that Message-ID:
<3f*********************@dread11.news.tele.dk> from The Plankmeister
contained the following:
http://www.mysite.com/main.php?show_...3%26month%3D10

You can see the & and = characters have been substituted for the URL-safe
equivalents. I'm sure it's PHP doing this, as I have a 99% identical page in
ASP which works fine. Is there an option I can switch to stop it
translating?


Using a simple ampersand is not valid. Try:

<option value="3&amp;year=2002&amp;month=10">October 2002</option>
etc...
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
On Mon, 8 Dec 2003 15:07:35 +0100, "The Plankmeister"
<pl******************@hotmail.com> wrote:
I have the following chunk of html output by my PHP script:

<select id="show_page" name="show_page">
<option value="3&year=2002&month=10">October 2002</option>
<option value="3&year=2003&month=10">October 2003</option>
<option value="3&year=2003&month=11">November 2003</option>
<option value="3&year=2003&month=12">December 2003</option>
</select>

But when I select one of these from the list and click submit, instead of
appearing like this in the address bar:

http://www.mysite.com/main.php?show_...=2002&month=10

It appears like this instead:

http://www.mysite.com/main.php?show_...3%26month%3D10

You can see the & and = characters have been substituted for the URL-safe
equivalents. I'm sure it's PHP doing this, as I have a 99% identical page in
ASP which works fine. Is there an option I can switch to stop it
translating?


Sounds more like it's the browser (correctly) doing it. You're breaking the
HTML 4.0 standard in your code having a bare & for starters, but anyway the
main issue is that the browser is reacting correctly: in order to get that
value passed for that option, it must be URL encoded.

You can't cause a single option to set multiple values by abusing the value
attribute to try and form a URL like that and expect it to work. If it does,
it's a bug (almost certainly in the browser - I don't see where PHP or ASP
comes into it since it's simply going from the output HTML to the next page;
the server's not involved until it receives the GET request).

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.