[PHP] Re: HTML errors

2011-01-12 Thread Pete Ford

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:
  !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 lia href='index.php?page=$category'$replace/a/li;
}

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

…omehome/a/lilia href=index.php?page=servicesservices/a/lilia
h…

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


a href='index.php?page=services'services/a

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



Re: [PHP] Re: HTML errors

2011-01-12 Thread David McGlone
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:
!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 lia href='index.php?page=$category'$replace/a/li;
  }
  
  Validator Error:
  an attribute value must be a literal unless it contains only name
  characters
  
  …omehome/a/lilia
  href=index.php?page=servicesservices/a/lilia h…
  
  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
 
 a href='index.php?page=services'services/a
 
 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

2011-01-11 Thread David Robley
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 lia href='index.php?page=$category'$replace/a/li;
 }
 
 Validator Error:
 an attribute value must be a literal unless it contains only name
 characters
 
 ?omehome/a/lilia
 href=index.php?page=servicesservices/a/lilia h?
 
 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.

a href=index.php?page=services



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