Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using & spits out an error

Status
Not open for further replies.

mickywall

Programmer
Sep 2, 2002
88
0
0
GB
using the & spits out an error, how can I get rid of it

Line 99, column 99: cannot generate system identifier for general entity "Category_Name"

<a href='default.asp?CategoryID=1&Category_Name=test'><strong>

thanks



 
It shouldn't be the & kicking out the error. That just concatenates a parameter to be passed to the referenced page. It doesn't even have to exist.
What else is going on there? What exactly is giving the error? Browser? ASP? Style checker?

traingamer
 
the only thing I can think of is that you are using strict xhtml, which mandates using &#38; for the ampersand. Don't worry, it will translate correctly into querystring variables once it is rendered on the page.

Try it and see what happens.

Code:
<a href='default.asp?CategoryID=1&#38;Category_Name=test'><strong>
 
like Jonty said, [ignore]&amp;[/ignore] will work as well. XHMTL specs do not allow for the reserved characters to exist anywhere in the code. That is why the correct link is:
Code:
<a href="default.asp?CategoryID=1&amp;Category_Name=test"><strong>
Check more here:
 
But you use an ampersand to create the &#38, so that would be a wrong solution no matter how many times you recursively replace it. The format you have is standard GET format for passing information.

Why are you using single quotes rather than double quotes? That's a sloppy work around for VBScript ASP users. Is it choking on the underscore character?

I tried your exact code in IIS on Windows XP SP2 and it worked fine.

Lee
 
Like the guys say, swap the & for &amp; or &#38; and the validator will like it. I'm not aware of any browser that will have problems with it as-is though.

Lee:

As far as the spec's concerned, an ampersand always marks the beginning of a character entity - &amp; &copy; &#123; etc. That's why the validator gives that particular error, it sees
Code:
<a href='default.asp?CategoryID=1&Category_Name=test'><strong>
and tries to find an entity called [tt]&Category_Name[/tt]. There isn't one, so it complains. Using an [tt]&amp;[/tt] instead allows you to say "this is an actual ampersand character, not the start of an entity". It's like using [tt]&lt;[/tt] to stop "<" characters confusing the browser.

Oh, and single quotes are just as valid as double quotes in (X)HTML. Most of us may prefer the double variety, but live and let live, eh?


-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
There is No browser problems with it, it works fine the issue is when I validate the page it spits out the error.
 
Just use
Code:
<a href='default.asp?CategoryID=1&#38;Category_Name=test'><strong>
and it will validate.
 
I didn't realize that you had to "escape" the ampersand in quotes, too. Thanks for the info on that.

As for the single quotes, the only examples I've seen on the W3C site when I've checked have used double quotes. I couldn't find anything on using single quotes when I looked at the XHTML 1.0 page referenced above.

Lee
 
Just found a reference to using single quotes, so I stand corrected.

Lee
 
Good to know about the & . That's why I like these forums - I learn something whether I want to or not. [blush]

traingamer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top