|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
W3 Validator trouble with GET variables?
Here's the problem i'm having... in trying to validate my page against the XHTML 1.0 Strict DTD. I'm getting a load error with the ampresand in the URL of my anchor tags...
<a href="concert.php?id=22&name=Nine+Inch+Nails%3A+Fragility+V2.0+Tour"> The errors are:
All the errors seem ot point to the ampresand... but the ampresand, or even "name", isn't a real part of my html... why should the validator care what's in an href attribute? Is this an error within the validator, or is there something i'm doing wrong? |
|
#2
|
||||
|
||||
|
You cannot use ampersands in your HTML, as it is not valid... all non alpha chars must be encoded using the ISO standard. E.g. & = &
Another thing you should be doing is encoding all your URL's - this has been a standard since the birth of HTTP, but no-one does it..... me included ![]() |
|
#3
|
||||
|
||||
|
The ampersand isn't really a part of my HTML; the ampersand is a part of the name/value pairs...
When listing more than one variable in the query string, you seperate them with ampersands... I am doing a urlencode() [PHP] on the variables passed within the querystring, which converts the ampersands into %26... I assume that if i were to do this on the entire query string, it wouldn't get interpretted properly on the other page. |
|
#4
|
||||
|
||||
|
You only separate your name/value pairs with & and ? in the querystring of your browser - not your source... & should be %26 - I was wrong with the ISO - that's for your HTML text, not the HREF values.
Try it and see. |
|
#5
|
||||
|
||||
|
So a proper anchor tag should read:
<a href="concert.php?id=22%26name=Nine+Inch+Nails%3A+Fragility+V2.0+Tour"> And this would pass id and name accordingly? *update* I just tried (in the case of PHP) doing: PHP Code:
This causes the URL to look like: http://localhost/concert.php?id%3D2...ility+V2.0+Tour And the PHP $_GET array to print with a key of id=22&name=Nine_Inch_Nails:_Fragility_V2_0_Tour and no value... |
|
#6
|
||||
|
||||
|
UGH - Me again - please disregard my second post (posted @ 3:30am :p) - I was right the first time - your &'s should be written as & in URL's. Here's the quote from W3C, plus I just made a quick little experiment to check I'm not insane :P
Quote:
Ater the initial '?', name/value pairs should be separated by '&' Actual name/value pair strings, should be encoded using the %XX format. This will then allow you to use unsafe strings in your querystrings - '&' encoded to it's %XX format equivelant, for example, will then be interpretted correctly as a string, and not an entity separator. |
|
#7
|
||||
|
||||
|
Well stumpy, as it turns out you were right...
To conclude, for others who've been following along, this is my resulting URL: <a href="concert.php?id=22&name=Nine+Inch+Nails%3A+Fragility+V2.0+Tour"> & is something that satisfies both the validator and the functionality of my site... It just seems kind of strange I guess... One thing that confuses me, from your quote... "...will suffice to terminate the entity, but some browsers get this wrong; the safest thing to do is to terminate all entities with a semicolon..." I guess this means not all browsers will handle that properly? I hope its safe to assume that only the jurrassic browsers will stumble... Again, thanks for your help and research Stumpy. |
|
#8
|
||||
|
||||
|
For the record - straight from the XHTML 1.0 spec (it's suprisingly easy to understand!):
Quote:
|
|
#9
|
||||
|
||||
|
Ohhh... I mis-interpreted it then...
In order to ensure that documents are compatible with historical HTML user agents... So this in theory should work with all browsers then? I completely understand it... I've used entities in XML documents before, so I understand the concepts behind it... Just can't see converting all my URL's to comply with the & |
|
#10
|
|||
|
|||
|
Hi,
Im having the same problem, I've tried substituting the ampersand for the ISO code, but still no joy. My code now reads <a href="index.cfm?linkID=261&toplevel=261" id="Choose COurse">Choose Your Course</a> But I still get the error in the validator: cannot generate system identifier for general entity "toplevel" Please Help?!?!? Thanks in advance |
|
#11
|
||||
|
||||
|
Post the URL to the page
|
|
#12
|
|||
|
|||
|
Hi,
Thanks for the reply, sorted now, it was the space in the id that cause the error. Thanks again |
|
#13
|
||||
|
||||
|
Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Advanced Web Development > W3 Validator trouble with GET variables? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|