Advanced Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignAdvanced Web Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 26th, 2004, 06:25 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 9
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:
  • cannot generate system identifier for general entity "name"
  • general entity "name" not defined and no default entity
  • reference not terminated by REFC delimiter
  • reference to external entity in attribute value

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?

Reply With Quote
  #2  
Old February 27th, 2004, 08:58 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old February 27th, 2004, 11:18 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 9
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.

Reply With Quote
  #4  
Old February 27th, 2004, 11:22 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.

Reply With Quote
  #5  
Old February 27th, 2004, 11:27 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 9
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:
<a href="concert.php?".urlencode("id=$id&name=$title")."\">" 


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...

Reply With Quote
  #6  
Old February 27th, 2004, 07:37 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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:
“unknown entity ‘FOO’”

The validator has found an entity (something like &this;) that it doesn't recognize. There are a few possibilities:

* A reference to a URI that uses & as a separator between parameters, such as "http://example.org/prog?x=1&y=2".

To solve this problem, simply replace all the &'s in attribute values with & (user agents will convert them back before following the links.)

Another way to get around this problem is for the author of the CGI program to allow a different value to be used between arguments, like ';' or '|', which would allow the link to be coded as e.g. <a href="http://example.org/prog?x=1;y=2">

* An unterminated entity; for instance, this&ampthat for "this&that", which the validator (correctly) interprets as a request for the entity &ampthat;. Technically, any non-alphanumeric character (such as a space) 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, turning our example into this&that.

* The entity " in conjunction with the HTML 3.2 DOCTYPE. This entity was accidentally omitted from the most recent version of the HTML 3.2 DTD. You should be able to ignore this error safely, though if you wish, you can replace " with the equivalent character entity ".
To reiterate:
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.

Reply With Quote
  #7  
Old February 28th, 2004, 12:00 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 9
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.

Reply With Quote
  #8  
Old February 28th, 2004, 12:55 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
For the record - straight from the XHTML 1.0 spec (it's suprisingly easy to understand!):
Quote:
C.12. Using Ampersands in Attribute Values (and Elsewhere)

In both SGML and XML, the ampersand character ("&") declares the beginning of an entity reference (e.g., ® for the registered trademark symbol "®"). Unfortunately, many HTML user agents have silently ignored incorrect usage of the ampersand character in HTML documents - treating ampersands that do not look like entity references as literal ampersands. XML-based user agents will not tolerate this incorrect usage, and any document that uses an ampersand incorrectly will not be "valid", and consequently will not conform to this specification. In order to ensure that documents are compatible with historical HTML user agents and XML-based user agents, ampersands used in a document that are to be treated as literal characters must be expressed themselves as an entity reference (e.g. "&"). For example, when the href attribute of the a element refers to a CGI script that takes parameters, it must be expressed as
http://my.site.dom/cgi-bin/myscript...guest&name=user rather than as
http://my.site.dom/cgi-bin/myscript...guest&name=user.

Reply With Quote
  #9  
Old February 28th, 2004, 09:53 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 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 &

Reply With Quote
  #10  
Old May 19th, 2004, 08:13 AM
Mattastic Mattastic is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 8 Mattastic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #11  
Old May 19th, 2004, 08:44 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Post the URL to the page

Reply With Quote
  #12  
Old May 19th, 2004, 08:47 AM
Mattastic Mattastic is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 8 Mattastic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

Thanks for the reply, sorted now, it was the space in the id that cause the error.

Thanks again

Reply With Quote
  #13  
Old May 22nd, 2004, 03:28 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 52 sec
Reputation Power: 10
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Quote:
Originally Posted by Mattastic
Hi,

Thanks for the reply, sorted now, it was the space in the id that cause the error.

Thanks again
Ugh - can't believe I missed that too!! Zzzzzzzzzz

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignAdvanced Web Development > W3 Validator trouble with GET variables?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek