简体   繁体   English

W3C验证出错

[英]Error at W3C Validation

I'm trying to make a website, but when I try to validate at W3C, there are 2 errors happening: 我正在尝试建立一个网站,但是当我尝试在W3C验证时,发生了2个错误:

 Line 28, Column 7: Stray end tag head.
</head>
Error Line 29, Column 6: An body start tag seen but an element of the same type was already open.
<body>

My code is: 我的代码是:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="pt-br">
<!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>SpotBOT - Engenharia Mecânica Cotidiana</title>
<meta name="description" content="Página pessoal sobre enganharia mecânica, faculdade, dificuldades, trabalhos e realizações na área.">
<link rel="apple-touch-icon" href="/icon-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/icon-iphone4.png" />
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="../css/main.css">
<script src="../js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src="../WYSIWYG/ckeditor.js"></script>
<?php
include("db_connect.php");
if (!isset($_SESSION)) session_start("Spotbot");
if(isset($_GET['page'])) {$page = $_GET['page'];}else {$page = "index";}
$query_select=mysql_query("SELECT permissao FROM indexpage WHERE pagename = '$page'")or print (mysql_error());;
if (mysql_num_rows($query_select) == 0){$nivel_necessario = 1;}
while($linha = mysql_fetch_array($query_select)){$nivel_necessario = $linha['permissao'];}
if(!isset($_SESSION['UsuarioID'])){$_SESSION['UsuarioNivel'] = "1";}
if ($_SESSION['UsuarioNivel'] < $nivel_necessario) {
session_destroy();
header("Location: http://spotbot.in?page=permission"); exit;
}
?>
<script>
    window.onload = function() {
        CKEDITOR.replace( 'texto' );
    };
</script>
</head>
<body>
<?php include_once("analyticstracking.php") ?>
<!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]--> 

<!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->
<div lang="pt-br" class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a>
      <?php include("menu.php");?>
    </div>
  </div>
</div>
<div class="container" lang="pt-br"> 
  <!-- Main hero unit for a primary marketing message or call to action -->
  <div class="hero-unit">
    <?php
            if(isset($_GET['page'])) {$page = $_GET['page'];}
            else {$page = "index";}
            $query_select=mysql_query("SELECT * FROM indexpage WHERE pagename = '$page'")or print (mysql_error());;
            if (mysql_num_rows($query_select) >= 1){
            while($linha = mysql_fetch_array($query_select)){
            $title = utf8_encode($linha["title"]);
            $text = utf8_encode($linha["text"]);
            $link= utf8_encode($linha["link"]);
            $button= utf8_encode($linha["button"]);
            }
                echo "<h2>$title</h2>
                <div id='post-data'><p>$text<br/></p></div>";
                if ($button != ""){echo "<p><a href='$link' class='btn btn-primary btn-large'>$button &raquo;</a></p>";}
                echo "</div><!-- Example row of columns --><div class='row'>";
            $query_select=mysql_query("SELECT * FROM indexfooter WHERE pagename = '$page'")or print (mysql_error());;
            while($linha = mysql_fetch_array($query_select)){
            $title = utf8_encode($linha["title"]);
            $text = utf8_encode($linha["text"]);
            $link= utf8_encode($linha["link"]);
            $button= utf8_encode($linha["button"]);
            echo "<div class='span4'><h3>$title</h3>
                <p>$text<br/>";
                if ($button != ""){echo "<p><a href='$link' class='btn'>$button &raquo;</a></p>";}
                echo "</div>";
            }}
            else
            {
                echo "
                <h2>Página não encontrada</h2>
                <p>A página que você procura não existe ou foi deletada.<br/>
                <p><a href='http://spotbot.in' class='btn'>Voltar à pagina principal &raquo;</a></p></div>
                </div><!-- Example row of columns --><div class='row'>";
            }
            ?>
  </div>
  <hr>
  <footer>
    <div id="geral">
    <p><a href="https://plus.google.com/107266754114799149959?rel=author">Me encontre no Google +</a></p>
    <p>Spotbot&copy;  2013</p>
    <p>All rights reserved.</p>    </div>
  </footer>
</div>
<!-- /container --> 

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
<script>window.jQuery || document.write('<script src="../js/vendor/jquery-1.8.3.min.js"><\/script>')</script> 
<script src="../js/vendor/bootstrap.min.js"></script> 
<script src="../js/plugins.js"></script> 
<script src="../js/main.js"></script> 
</body>
</html>

Just edited with the full code. 刚编辑完整的代码。

I'm trying to find the error, but I cant find it. 我试图找到错误,但我找不到它。

Please, help me find this bug ;) 请帮帮我找到这个bug;)

In the actual HTML code generated, which you kindly uploaded for inspection, line 23 begins with U+FEFF ZERO WIDTH NO-BREAK SPACE. 在生成的实际HTML代码中 ,您需要上传以供检查,第23行以U + FEFF ZERO WIDTH NO-BREAK SPACE开头。 It is an invisible control character, which is completely valid as such in HTML, but it is taken as a data character. 它是一个不可见的控制字符,在HTML中完全有效,但它被视为数据字符。 No data characters except whitespace (and U+FEFF is by definition not whitespace in HTML) are allowed between elements in the head part. head元素之间不允许除空格之外的数据字符(并且U + FEFF在定义中不是 HTML中的空格)。 This means that any data character there (whether U+FEFF or FOOBAR) implicitly closes the head element and opens a body element (where data characters are allowed). 这意味着那里的任何数据字符(无论是U + FEFF还是FOOBAR)都会隐式关闭head元素并打开一个body元素(允许使用数据字符)。 This explains the error messages. 这解释了错误消息。

U+FEFF is the same character as the Byte Order Mark (BOM). U + FEFF与字节顺序标记 (BOM)的字符相同。 Apparently, a .php file has been saved in UTF-8 format with BOM at the very start. 显然,.php文件一开始就以带有BOM的UTF-8格式保存。 Although BOM is perfectly legal (and often useful) at the start of a UTF-8 datastream, it has a different meaning (as a data character) anywhere else. 尽管BOM在UTF-8数据流的开头是完全合法的(并且通常是有用的),但它在其他地方具有不同的含义(作为数据字符)。 PHP processors fail to remove the BOM when they insert the content of a .php file. PHP处理器在插入.php文件的内容时无法删除BOM。

So the problem should be fixed by opening the db_connect.php file in an editor and saving it in UTF-8 format without BOM . 因此,应该通过在编辑器中打开db_connect.php文件并将其保存为没有BOM的 UTF-8格式来解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM