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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inconsistent results from validator 2

Status
Not open for further replies.

jaygeeuk

Technical User
Jan 31, 2010
6
GB
A relative XHTML and PHP novice, I wonder if this is the forum for this topic:
I am validating the pages of website URL:
The pages are generated using PHP statements of the type:
include ("html/content.htm");
so that all pages start (view source) with a standard set of statements declaring DOCTYPE, charset etc.
The Validator, however, responds with a variety of different warnings for the different pages, including:

byte order mark found in utf-8
char "" not allowed
no character encoding found, falling back into utf-8
no characcter encoding at document level
etc.

Why this lack of consistency?
 
I don't know which validator you are using, because the one at the W3C works just fine, telling me the page validates correctly:


From the errors you are getting, it may well be that the validator you are using doesn't correctly parse out the UTF-8 BOM.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Thanks for your response.
That is the validator I have been using, accessed through the Firefox Web Developer toolbar.
This has worked well for identifying html errors, but I would like to understand why it decides to issue various warnings when the Doctype and charset statements should be and appear identical.
I do not have the experience to know how important these warnings are.
The validator is being used to try to track down the causes of inconsistencies in the rendering, not just across different browsers, but by the same browser for different pages that should be using the same layout. For example, the index (Home) page:
renders with the header division tight to the top of the page, which is what I would expect. Some pages, however, are rendered with a gap at the top. I have a division id = "wrapper" which contains all other divisions. Using the web developer toolbar for these pages shows that this is located with top = 18px which is the base line height. I simply cannot see the difference between the html/css for the different pages. The validator must see them differently and I thought that if I could understand why, I might see the difference in the html/css.
Your thoughts would be appreciated.
 
Personally, I'd ignore the warnings. The page validates, and you have the correct charset definition.

If any older browsers do have problems, then they're probably going to be too old to care about.

As to the gap, perhaps you could give a URL to one of the affected pages so I don't have to randomly click around your site for ages in a vague attempt to find one.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Typically:
The PHP is:
<?php
include("haheader.php");
haheader("Select news");
include("html/bodyheader.htm");
include("html/menu.htm");
?>
<div id = "content">
<h5>News Archive</h5>
<h6>Select one of these news items:</h6>
<?php
if ($dh = opendir("news")) {
while (false != ($file = readdir($dh))) {
if ($file != "." && $file != ".." ) {
$filenames[] = $file;
}
}
closedir($dh);
}rsort ($filenames);
foreach ($filenames as $file){
if ($fh = fopen("news/$file", "rt")) {
$title = fgetss($fh, 1024);
$title = fgetss($fh, 128);
echo "<p>" . $title . " ... ";
echo "<a href=\"newsshow.php?newsfilename=$file\">more</a></p>\n";
fclose($fh);
}
}
echo "</div>\n";
echo "<div id = \"content-right\">\n";
include ("html/newsshowright.htm");
echo "</div>\n";
include("html/bodyfooter.htm");
?>

Suggestions will be much appreciated.
 
For comparison the PHP for index.php is:

<?php
include("haheader.php");
haheader("Home");
include("html/bodyheader.htm");
include("html/menu.htm");
echo "<div id =\"content\">\n";
include("html/home.htm");
echo "</div>\n";
echo "<div id=\"content-right\">\n";
echo "<div id=\"newsflash\">\n";
include("html/newsflash.htm");
echo "</div>\n";
include("html/homeright.htm");
echo "</div>\n";
include("html/bodyfooter.htm");
?>

The PHP is identical until the content division is loaded. I have compared the source of the two pages and can find no reason for the difference. Also I cannot see how the CSS could account for the difference.
 
If I paste the source code for those two pages into TextPad, the newsselect.php page shows a "?" before the DOCTYPE.

This could mean you have some erroneous characters (perhaps an extra BOM, or possibly non-diaplayable whitespace chars) at the top of newsselect.php before haheader.php is included... or possibly even right at the bottom of the file.

If this is the case, and you genuinely cannot spot it in your text editor, a good way to fix it would be:

- Rename newsselect.php to something else (e.g. newsselect.old)

- Copy index.php and rename the copy to newsselect.php

- Copy the contents of newsselect.old BETWEEN BUT NOT INCLUDING the following lines into the newly-created newsselect.php:

Code:
include("haheader.php");
   ...
?>

If that gets rid of the space, then you know it was some dodgy characters in your original newsselect.php file.

If that doesn't work, I'd load your original version of newsselect.php and all the files that you include within it into TextPad and see if you can spot the erroneous characters (which TextPad will show up as "?").

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
When browser reaches your page, it runs it through its parser. While the code of all your pages seems exactly the same, after it is run through the browser's parser (the so-called generated code) is different for the pages that have a gap. Those pages have the included stylesheet in the body of the page, instead of the head. I have no idea why it appears that way, but IE8, FF3.5 and Chrome all show it like that. They all show the gap as well.

I would try to play around with different things (removing certain tags from the head, etc. and maybe try to create simple html pages (simply save the source) to see if that makes a difference. You can see the generated code with any developer tool (Firebug add-on for FF, plug-in for IE, native in Chrome), which should help you out in testing.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Gentlemen (BillyRayPreacherSon, Dan, Vragabond),

I thank you from the bottom of my heart.

I took a copy of index.php and saved it as test.php. I then replaced the specific code in the middle with the specific code from articleselect.php, which was one that generated a page that showed a space at the top and Bingo! The space disappeared.

How do you guys cope with this idiotic world where not only do different browsers produce different results, but also what appears to be identical code produces different results in the same browser?

That the Validator gave different warnings suggested that there was a difference in the text, but I never dreamt that it would be an invisible difference.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top