Re: HTML errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:35 PM -0500 1/11/11, David McGlone wrote:
Hi Everyone, I'm having a problem validating some links I have in a foreach.
Here is my code:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>

my PHP code:
$categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us',
'testimonials');
foreach($categorys as $category){
$replace = str_replace("_", " ", $category);
echo "<li><a href='index.php?page=$category'>$replace</a></li>";
}

Validator Error:
an attribute value must be a literal unless it contains only name characters

?ome>home</a></li><li><a href=index.php?page=services>services</a></li><li><a
h?

I have tried various combinatons and different doctypes. I'm beginning to
wonder if this code is allowed at all.


--
Blessings
David M.

David:

First of all, the type (strict or transitional) of DOCTYPE doesn't matter -- it only matters IF you are going to use deprecated HTML elements (transitional) or not (strict).

Second, your <li> (i.e., list) should start with a "type of list" tag, such <ol> for ordered list -- there are several different types (i.e., ol, ul, dir, menu, dl dt dd).

Third, you might try this:

echo("<li><a href=\"index.php?page=$category\">$replace</a></li>");

The Validator might be objecting to the way you use ' instead of ".

HTH's

Cheers,

tedd


--
-------
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux