473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

URL Parameters to meet W3C validation causes incorrect _GET parameterresults

Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as & (example: ./
index.php?a=1&B=2). But, if that is done, then the _GET or
_REQUEST array element names are incorrect. In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).

So, how do I get around this? Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?
Jul 17 '08 #1
8 5555
The KwikOne schrieb:
Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as & (example: ./
index.php?a=1&B=2). But, if that is done, then the _GET or
_REQUEST array element names are incorrect. In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).

So, how do I get around this? Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?
You shold read:
http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2
and:
urlencode();

Jul 17 '08 #2
..oO(The KwikOne)
>Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as & (example: ./
index.php?a=1&B=2).
You only do this if the URL is printed to an HTML page, for example in
an 'a' element:

<a href="./?a=1&amp;B=2">foo</a>

BTW: Don't write "index.html" or "index.php" in URLs, it's not necessary
and bad style.
>But, if that is done, then the _GET or
_REQUEST array element names are incorrect.
No. The &amp; is interpreted by the browser, the server will never see
it if you click that link.
>In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).

So, how do I get around this?
There's a bug somewhere in your code. Can you post a short code example
or page snippet which causes this problem? How does the final HTML code
for such a link look? Do you see something like

<a href="./?a=1&amp;amp;B=2">foo</a>

Notice the "double-encoding" of the ampersand. This could be one reason
for your problem.
>Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?
Nothing, because it shouldn't happen.

Micha
Jul 18 '08 #3
On Jul 18, 1:54*am, Michael Fesser <neti...@gmx.dewrote:
.oO(The KwikOne)
Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as &amp; (example: ./
index.php?a=1&amp;B=2).

You only do this if the URL is printed to an HTML page, for example in
an 'a' element:

<a href="./?a=1&amp;B=2">foo</a>

BTW: Don't write "index.html" or "index.php" in URLs, it's not necessary
and bad style.
But, if that is done, then the _GET or
_REQUEST array element names are incorrect.

No. The &amp; is interpreted by the browser, the server will never see
it if you click that link.
In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).
So, how do I get around this?

There's a bug somewhere in your code. Can you post a short code example
or page snippet which causes this problem? How does the final HTML code
for such a link look? Do you see something like

<a href="./?a=1&amp;amp;B=2">foo</a>

Notice the "double-encoding" of the ampersand. This could be one reason
for your problem.
Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?

Nothing, because it shouldn't happen.

Micha
Micha,
Actually I found that this problem only occurred when doing a
window.open in javascript;
such as window.open('/x.php?a=1&amp;b=B', etc);
So, I have found my workaround (personally I think it is a bug within
javascript in Firefox v3
since it did not seem to see failures when IE v7 was used).
So, instead of window.open('/x.php?a=1&amp;b=B', etc);
I now have it as: window.open('/x.php?a=1&'+'b=B', etc);
and it works OK and validation does not fail.
Jul 22 '08 #4
On Jul 17, 5:19*pm, Olaf Schinkel <tr...@schinkel.tvwrote:
The KwikOne schrieb:Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as &amp; (example: ./
index.php?a=1&amp;B=2). But, if that is done, then the _GET or
_REQUEST array element names are incorrect. In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).
So, how do I get around this? Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?

You shold read:http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2
and:
urlencode();
It states QUOTE...
For example, to use the URI "http://host/?x=1&y=2" as a linking URI,
it must be written <A href="http://host/?x=1&y=2"or <A
href="http://host/?x=1&amp;y=2">
END QUOTE
That is exactly what I stated above. However, it is now resolved, (see
my response to micha)
Jul 22 '08 #5
The KwikOne:
Actually I found that this problem only occurred when doing a
window.open in javascript;
such as window.open('/x.php?a=1&amp;b=B', etc);
Context is everything. Character references are not recognised in the
script element, so the "amp;" is part of the URL. Compare attributes
such as href, in which character references are recognised. See HTML
4.01 sec. 6.2:

http://www.w3.org/TR/html401/types.html#type-cdata
So, I have found my workaround (personally I think it is a bug within
javascript in Firefox v3
since it did not seem to see failures when IE v7 was used).
Firefox gets it right; Internet Explorer gets it wrong.

--
Jock
Jul 23 '08 #6
..oO(The KwikOne)
>Actually I found that this problem only occurred when doing a
window.open in javascript;
such as window.open('/x.php?a=1&amp;b=B', etc);
So, I have found my workaround (personally I think it is a bug within
javascript in Firefox v3
Depends.

In an external JS file character references like &amp; would not be
resolved, but they will be resolved within a 'script' element if the
document is written and delivered as XHTML.

In normal HTML and XHTML delivered as text/html this won't happen, so
IMHO the behaviour of Firefox is correct.
>since it did not seem to see failures when IE v7 was used).
So, instead of window.open('/x.php?a=1&amp;b=B', etc);
I now have it as: window.open('/x.php?a=1&'+'b=B', etc);
and it works OK and validation does not fail.
OK.

Micha
Jul 23 '08 #7
On Jul 23, 9:11*am, na...@infection.com wrote:
On Tue, 22 Jul 2008 14:06:38 -0700 (PDT), The KwikOne <kerryku...@gmail.com>
wrote:
On Jul 17, 5:19*pm, Olaf Schinkel <tr...@schinkel.tvwrote:
The KwikOne schrieb:Since to have a page validate (HTML and XHTML) you should have your
URL parameters separated by the appropriate separator. However, if an
ampersand is used it needs to be expressed as &amp; (example: ./
index.php?a=1&amp;B=2). But, if that is done, then the _GET or
_REQUEST array element names are incorrect. In the example the _GET
array will be:
_GET['amp;a'] = 1 (instead of _GET['a'] = 1) and _GET['amp;B'] = 2
(instead of _GET['B'] = 2).
So, how do I get around this? Is there any other way other than
looping and stripping the 'amp;' part prior to actually looking for
parameters? What do others do in this situation?
You shold read:http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2
and:
urlencode();
It states QUOTE...
For example, to use the URI "http://host/?x=1&y=2" as a linking URI,
it must be written <A href="http://host/?x=1&y=2"or <A
href="http://host/?x=1&y=2">
END QUOTE
That is exactly what I stated above. However, it is now resolved, (see
my response to micha)

I dont think the W3C people even know the diference between a URI and URL
A matter of symantics only since a URL is a linked URI (or link to the
URI)
Jul 23 '08 #8
On Jul 23, 5:09*am, Michael Fesser <neti...@gmx.dewrote:
.oO(The KwikOne)
Actually I found that this problem only occurred when doing a
window.open in javascript;
such as window.open('/x.php?a=1&amp;b=B', etc);
So, I have found my workaround (personally I think it is a bug within
javascript in Firefox v3

Depends.

In an external JS file character references like &amp; would not be
resolved, but they will be resolved within a 'script' element if the
document is written and delivered as XHTML.

In normal HTML and XHTML delivered as text/html this won't happen, so
IMHO the behaviour of Firefox is correct.
since it did not seem to see failures when IE v7 was used).
So, instead of window.open('/x.php?a=1&amp;b=B', etc);
I now have it as: window.open('/x.php?a=1&'+'b=B', etc);
and it works OK and validation does not fail.

OK.

Micha
Micha,
Well, one of them (IE or FF) gets it wrong (with FF amp; was prefixed
to the argument name, and IE worked OK) and when I split up the url as
above they both work OK. (PS: the page was XHTML 1.0 Transitional)
And, the original problem was noted within an onclick (<img ...
onclick="javascript:window.open( ..."), and
also noticed within an inline script element function. Whether or not
it works in a linked script is
unknown (I have not had the time to set up a test case).
Jul 23 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ravi & Paami | last post by:
After I tried upgrading my php version from 3 to 4, all my code which passes parameters between web pages have stopped working. Not sure what the problem is. Have tried defining the parameters in...
0
by: James | last post by:
Hi, I am making a basic DVD shop and after having produced code which displays a list of DVDs from my database, I implemented a search facility which enables the user to search by title, director...
3
by: Miles Davenport | last post by:
Apologies for cross-posting, but I felt this query would be relevant to HTML and PHP forums. I am currently modifying a PHP IMAP script which allows the user to view their email via a web...
6
by: HH | last post by:
I'm learning to design web applications with php, mysql, and apache from a book. I copied a sample application called guestbook 2000 that came with the CD in the book to my htdocs folder, but...
3
by: DCB | last post by:
Hello. I have an easy question, likely, that has me in a headspin. I have an include file to a frames based site that basically forces frames on the end user if they visit the site and hit a...
0
by: Cleako | last post by:
Here is my dilema. I have a validation summary that I use soley for my Required Field Validators. I have it setup to run from a Page.Validate call in the code-behind, this is because I need to...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
5
by: tuananh87vn | last post by:
hi, i want to use ajax to validate a form. here is my work including 2 files, main.html and process.php main.html <script language="javascript"> //initialize xmlhttprequest object... var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.