Re: [PHP] Re: HTML errors
On Wednesday, January 12, 2011 04:14:42 am Pete Ford wrote: > On 12/01/11 03:35, David McGlone wrote: > > Hi Everyone, I'm having a problem validating some links I have in a > > foreach. > > > > Here is my code: > >> > > "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 "$replace"; > > } > > > > Validator Error: > > an attribute value must be a literal unless it contains only name > > characters > > > > …ome>home > href=index.php?page=services>services > > > I have tried various combinatons and different doctypes. I'm beginning to > > wonder if this code is allowed at all. > > All the other replies are talking nonsense (especially Daniel ;) ! > There's no reason why HTML with single-quoted attributes isn't valid, so in > principle your expected output of > > services > > should be OK. > > The real challenge is to understand why the code fragment you have > presented is losing the single quotes: are you *sure* this is exactly what > you have in your file (i.e. have you copied it to the posted message > properly) ? Thanks Pete. Funny story. Ya'll better not laugh, especially you Denial, oops I mean Daniel ;-) Anyway, All of us would never have fixed this error. We could have added double quotes, single quotes and every combination even the worlds best programmer would use and it wouldn't have gotten us anywhere. Thats because if your working on the wrong file. :-) -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML errors
On 12/01/11 03:35, David McGlone wrote: Hi Everyone, I'm having a problem validating some links I have in a foreach. Here is my code: 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 "$replace"; } Validator Error: an attribute value must be a literal unless it contains only name characters …ome>homeservices All the other replies are talking nonsense (especially Daniel ;) ! There's no reason why HTML with single-quoted attributes isn't valid, so in principle your expected output of services should be OK. The real challenge is to understand why the code fragment you have presented is losing the single quotes: are you *sure* this is exactly what you have in your file (i.e. have you copied it to the posted message properly) ? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML errors
David McGlone wrote: > Hi Everyone, I'm having a problem validating some links I have in a > foreach. Here is my code: > "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 "$replace"; > } > > Validator Error: > an attribute value must be a literal unless it contains only name > characters > > ?ome>home href=index.php?page=services>services > I have tried various combinatons and different doctypes. I'm beginning to > wonder if this code is allowed at all. > > In this tag you aren't getting the href value enclosed in quotes which I suspect would trigger the validator error. Cheers -- David Robley "I'll take that," said Tom appropriately. Today is Boomtime, the 12nd day of Chaos in the YOLD 3177. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php