1

我正在处理的网站出现以下验证错误

 Line 1, Column 1: non SGML character number 6

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.…

在 FireFox 源代码查看器中,以下行的文本为红色

DOCTYPE
HEAD
META CHARSET
/HEAD
BODY
2 Paragraph tags (that are properly opened and closed.

当我使用 Web 开发人员 FireFox 插件并选择“编辑 HTML”选项时,有一个红点,所有标签都<title>消失了。也没有正文标签,在 FireFox 源代码查看器中显示为红色的两个段落标签也不见了。换句话说,红色表示某种错误,但我在源代码中看不到任何错误。

此处显示了指示为错误的部分:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>

</head>
<body class="page">

<p>
    <div class="photo-box photo-box-right" id="photo-box-test-image-619">
        <div class="photo-box-photo">
            <img src="http://localhost/assets/uploads/images/logo.png" title="Test image" alt="Test image" />
        </div>
        <div class="photo-box-title">
            <span class="photo-box-head" title="Test image">Test image</span>
        </div>
    </div>
    Qualitative data approximates, characterizes or describes but does not measure the attributes, characteristics, properties of a phenomenon.  Data could take the form of textual transcriptions of interviews, focus groups or dialogues, photographs, audio and video recordings.
</p>
<p>
    <div class="photo-box photo-box-left" id="photo-box-test-image-476">
        <div class="photo-box-photo">
            <img src="http://localhost/assets/uploads/images/sparta.jpg" title="Test image" alt="Test image" />
        </div>
        <div class="photo-box-title">
            <span class="photo-box-head" title="Test image">Test image</span>
        </div>
    </div>
    Quantitative data defines attributes in terms of values with numerical significance and can be represented as matrixes of numbers of responses, maps, tables or graphs.
</p>

I can not see any errors in the HTML. I see no hidden control characters in any normal editor that I can get my hands on (Notepad++, UltraEdit, Notepad, Wordpad) but I do see it in the "Edit HTML" screen of the Web Developer toolbar.

Here is what I have done to try and resolve this:

  1. Recreate the file and retyping the supposed affected lines.
  2. Used various text editors to try and see the wrong file.
  3. Removed all recently added content and code in the file to see if this stops at any point (no luck...)
  4. Read all the posts I can find about "non-SGML character" I could find here and on Google, nothing seem to answer my question.
  5. Deleted the post in the database and recreated that (for incase this is a problem with database content). Not resolved.
  6. Converted all tables to MyISAM (some, including the content table, were InnoDB)
  7. Checked if other pages that does not draw its content from the database has the same problem (such as contact form) and it does the same.
  8. Played around with various character sets and encodings in my database and HTML source, as well as my PHP ini file. None affect the outcome.
  9. Changed the code page in all my text editors to various types to try and see this hidden non-SGML character.
  10. Copied all the system and application files (excluding the obvious changes such as CSS and templates and modified modules) over from another site based on the same version of CodeIgniter that works well.

Anything else you think I can do?

From the above, I conclude that either the custom modules (unlikely), the CSS stylesheets, the added jQuery libraries that are different between the sites (uniform.js, buttons.js) or the templates and views used is having some sort of pukefest on my happiness.

Please advise if you can think of something else I have missed...

Thanks!

Kobus

EDIT: Now that I am allowed to add images, I decided to make a few screenshots to explain the problem better. Maybe it helps... I initially thought it may be the whitespace in the title tag, but wasn't that...Screenshot 1Screenshot 2

4

2 回答 2

0

It may be an encoding issue. Make sure that the file is saved as ANSI or UTF8 WITHOUT the BOM marker. The BOM marker may cause this issue.

In Notepad++, the fourth menu is for encoding, you can easily change this there.

于 2012-10-06T09:51:40.887 回答
0

Hi everyone who responded,

Thank you so much for all your efforts to help, in particularly @MadaraUchiha for their patience and effort.

The problem was eventually solved after I have uploaded the site to my web hosting space (thanks @JukkaK.Korpela who suggested this), and tried to access the page. On my local dev environment, the CodeIgniter error screen does not display (will have to figure out why) but on my hosting space, I got a clear indication of what the error was:

Cannot modify header information - headers already sent by (output started at /usr/www/users/imperoco/demo/application/helpers/bootstrap_helper.php:1)

In another file (a CodeIgniter helper file) there was a - in front of the <?php tag. So - somehow, when I was editing it, I must've added a rogue -. Removed it, and now the page displays fine.

Thank you so much for your time. Now that I know my development environment does not display the error, I can work to resolve that, to prevent issues such as this the next time around. :-)

Kind regards,

Kobus

于 2012-10-06T10:39:32.530 回答