How do I validate (w3c validation) the following line of code (HTML TIDY)

I am getting the flollowing warming message:
line 89 column 3761 - Warning: <a> escaping malformed URI reference

on the following code that I am generating on the fly:

print "<td><a href=\"editVariant.php?mark_id=$mark_id&amp;mark_name=$mark_name&amp;mark_desc=$mark_desc&amp;id=$id&amp;name=$var_name&amp;desc=$var_desc&amp;file1=$file1&amp;file2=$file2\">Edit </a> |<a href=\"uploadFiles.php?var_id=$id&amp;name=$var_name&amp;desc=$desc&amp;file1=$file1&amp;file2=$file2\">Manage files</a>  | <a href=\"deleteVariant.php?id=$id&amp;name=$var_name&amp;desc=$var_desc&amp;file1=$file1&amp;file2=$file2\">Delete </a>| ";

Any suggestions?
Thanks in advance.
awarraicAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hernst42Connect With a Mentor Commented:
The problem are the spaces in the href-attribute. Spaces (and other chars) must be escape. So replace all occurences of $var in your string with " . urlencode($var) . " and your file should validate.
0
 
hernst42Commented:
Code looks ok, but might be a problem depending of the content of a variable. Try to use htmlentities(urlencode($variable)) for each variable you output in that code.

Can ypu post the line that generate the error in the validator?
0
 
awarraicAuthor Commented:
Sure, here's the code output where it's giving the error:
<table><caption>Manage Variants</caption><tr><th>Variant Thumbnail</th><th>Variant Name</th><th>Action</th></tr><tr><td class='table_thumbnail'> <img src='/admin/download/blockS_blk_green_large.gif' alt=' thumbnail' /></td><td> </td><td><a href="editVariant.php?mark_id=152&amp;mark_name=Block S Trademark&amp;mark_desc=The Block S represents the primary mark of Hexon Netoworks. Pay strict attention to its design character as any deviation is deemed unauthorized.&amp;id=210&amp;name=&amp;desc=Trademark&amp;file1=blockS_blk_green_large.gif&amp;file2=blockS_blk_green_large.gif">Edit </a>
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Rok-KraljCommented:
Instead of space in href attribute write:

%20
0
 
Oddsen84Commented:
Also for debugging purposes you should consider splitting the code into separate lines. This makes it so much easier to find mistakes. Instead when you get a error message for line "xxx" and have to go trough hundreds of characters you only maybe have 10 or 20 characters to go trough.
0
 
awarraicAuthor Commented:
Yea, sorry, I think this is the piece of code where's the error is. Can't break it further I think because there're so many variables that I am passing to the next page. I don't think I have any extra space in there at though.

><a href="editVariant.php?mark_id=152&amp;mark_name=Block S Trademark&amp;mark_desc=The Block S represents the primary mark of Hexon Netoworks. Pay strict attention to its design character as any deviation is deemed unauthorized.&amp;id=210&amp;name=&amp;desc=Trademark&amp;file1=blockS_blk_green_large.gif&amp;file2=blockS_blk_green_large.gif">
0
 
Oddsen84Commented:
Ok just a suggestion free from me to you :-) hehe
0
 
awarraicAuthor Commented:
Thanks much, this function worked great, all warmings are goine. thanks.
0
All Courses

From novice to tech pro — start learning today.