** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antho

    ** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

    Firstly, thank you to everyone that replied to my OP. I am new to the PHP
    world and so its great that there are people out there who are prepared to
    share their knowledge.

    Anyway, I am developing a website on my home pc. I dont have server-space
    outside my home. So, I needed to be able to validate my code by file
    upload to the W3C's html validator at http://validator.w3.org/

    This solution is so easy, I am surprised that my extensive googling didnt
    provide an answer as it does return MANY hits relating to this search. I
    thought I would post this so that there is something **out there** for
    others that come across this problem.

    My original problem was ...

    [color=blue]
    > I have installed Apache2 and PHP on my Mdk 9.2 box. I have made an
    > info.php page to test if php is working. It appears that it is as my
    > info.php is displayed as it should be on my web-browser.
    >
    > The only thing is, when I upload the info.php file to the W3C validator,
    > it complains:
    >
    > **Sorry, I am unable to validate this document because its content type
    > is application/octet-stream, which is not currently supported by this
    > service.**[/color]

    The solution is very easy. Thank you to Michael Fuhr for the tip!
    [color=blue][color=green]
    >> Some browsers on some systems use the file ~/.mime.types,
    >> /etc/mime.types, or another such file to determine an uploaded file's
    >> Content-Type. Creating or editing one of those files and adding a line
    >> such as "text/html php" should do the trick, although I don't know what
    >> other implications that might have.[/color][/color]

    On Mandrake Linux 9.2, in the file /etc/mime.types change this line:

    text/html html htm

    to

    text/html html htm php

    The W3C validator will then start accepting the output of php files.

    Yippee!! No more ** content type is application/octet-stream ** problem!

    Thanks once again for helping me out!!!

    --
    == cBe! ==== @ntho === 8 ^ ) =============== =============== ==========
    == Famous last words from Registered Linux User #296186 =============
    == "I would have made a good Pope." - Richard M. Nixon (1913-1994) ==

  • Michael Fuhr

    #2
    Re: ** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

    Antho <prevent-shun@coz.spam.s ux> writes:
    [color=blue][color=green]
    > > I have installed Apache2 and PHP on my Mdk 9.2 box. I have made an
    > > info.php page to test if php is working. It appears that it is as my
    > > info.php is displayed as it should be on my web-browser.
    > >
    > > The only thing is, when I upload the info.php file to the W3C validator,
    > > it complains:
    > >
    > > **Sorry, I am unable to validate this document because its content type
    > > is application/octet-stream, which is not currently supported by this
    > > service.**[/color]
    >
    > The solution is very easy. Thank you to Michael Fuhr for the tip![/color]

    John Dunlop really deserves the thanks -- he noticed that you were
    uploading a file for validation, while I initially assumed (incorrectly)
    that you were submitting a URI.
    [color=blue][color=green][color=darkred]
    > >> Some browsers on some systems use the file ~/.mime.types,
    > >> /etc/mime.types, or another such file to determine an uploaded file's
    > >> Content-Type. Creating or editing one of those files and adding a line
    > >> such as "text/html php" should do the trick, although I don't know what
    > >> other implications that might have.[/color][/color]
    >
    > On Mandrake Linux 9.2, in the file /etc/mime.types change this line:
    >
    > text/html html htm
    >
    > to
    >
    > text/html html htm php
    >
    > The W3C validator will then start accepting the output of php files.[/color]

    Not so fast. Your browser is probably uploading the source PHP
    file, not the output. Try again at the Extended File Upload
    Interface:

    W3C's easy-to-use markup validation service, based on SGML and XML parsers.


    Turn on "Show Source" and then upload one of your PHP files. When
    you get the validation result, scroll down to "Source Listing" and
    you should see your PHP code, not the output of that code. If you
    want to validate the output, which is what you should be validating,
    then you'll have to make sure the PHP code is actually run, either
    by the web server or via the command-line interface. You'll have
    to save the output somewhere and upload *that* file, not the .php
    file that generated the output.

    --
    Michael Fuhr

    Comment

    • Antho

      #3
      Re: ** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

      Posted by Michael Fuhr on Tue, 18 Nov 2003 20:44:36 -0700:
      [color=blue]
      > Antho <prevent-shun@coz.spam.s ux> writes:
      ><snipped stuff>[color=green]
      >> The solution is very easy. Thank you to Michael Fuhr for the tip![/color]
      >
      > John Dunlop really deserves the thanks -- he noticed that you were
      > uploading a file for validation, while I initially assumed (incorrectly)
      > that you were submitting a URI.
      >
      ><snipped stuff>
      > Not so fast. Your browser is probably uploading the source PHP
      > file, not the output. Try again at the Extended File Upload
      > Interface:
      >
      > http://validator.w3.org/file-upload.html
      >
      > Turn on "Show Source" and then upload one of your PHP files. When
      > you get the validation result, scroll down to "Source Listing" and
      > you should see your PHP code, not the output of that code. If you
      > want to validate the output, which is what you should be validating,
      > then you'll have to make sure the PHP code is actually run, either
      > by the web server or via the command-line interface. You'll have
      > to save the output somewhere and upload *that* file, not the .php
      > file that generated the output.[/color]

      ok. You are right, of course! My php code does appear. Are
      you saying that I could **never** validate a file directly from my
      hard-drive? I have to load the page in the browser, copy page source, save
      file as html, then upload **that** file to the validator.

      I guess its because it is coming from the folder /var/www/etc/etc, and
      therefore isnt really being "served".

      --
      == cBe! ==== @ntho === 8 ^ ) =============== =============== ==========
      == Famous last words from Registered Linux User #296186 =============
      == "I would have made a good Pope." - Richard M. Nixon (1913-1994) ==

      Comment

      • Michael Fuhr

        #4
        Re: ** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

        Antho <prevent-shun@coz.spam.s ux> writes:
        [color=blue]
        > Posted by Michael Fuhr on Tue, 18 Nov 2003 20:44:36 -0700:
        >[color=green]
        > > Turn on "Show Source" and then upload one of your PHP files. When
        > > you get the validation result, scroll down to "Source Listing" and
        > > you should see your PHP code, not the output of that code. If you
        > > want to validate the output, which is what you should be validating,
        > > then you'll have to make sure the PHP code is actually run, either
        > > by the web server or via the command-line interface. You'll have
        > > to save the output somewhere and upload *that* file, not the .php
        > > file that generated the output.[/color]
        >
        > ok. You are right, of course! My php code does appear. Are
        > you saying that I could **never** validate a file directly from my
        > hard-drive? I have to load the page in the browser, copy page source, save
        > file as html, then upload **that** file to the validator.
        >
        > I guess its because it is coming from the folder /var/www/etc/etc, and
        > therefore isnt really being "served".[/color]

        Right -- something has to run the PHP code so you can get the output,
        and your browser doesn't do that. If the page doesn't depend on
        being run in a web server context, then you could get to a shell
        prompt and run "php foo.php > foo.html" and then upload foo.html
        to the validator. But if the page depends on form data or other
        information from the web server, then you'll have to use your browser
        or a utility such as wget or curl to issue an HTTP request for the
        page and then save the output.

        --
        Michael Fuhr

        Comment

        • Warren Oates

          #5
          Re: ** SOLUTION: Apache2, PHP, and the W3C xhtml validator **

          In article <pan.2003.11.18 .23.35.55.22650 5@coz.spam.sux> ,
          Antho <prevent-shun@coz.spam.s ux> wrote:

          :My original problem was ...
          :
          :
          :> I have installed Apache2 and PHP on my Mdk 9.2 box. I have made an
          :> info.php page to test if php is working. It appears that it is as my
          :> info.php is displayed as it should be on my web-browser.
          :>

          Interesting. I didn't see your original post, but I had exactly the same
          error on a Mac. I tried to upload "index.php" to The Validator and I got
          the same error message. In my case, I reckon it was Mozilla who thought
          that the .php extension meant she was uploading a binary file. I changed
          it to "index.html " and the problem was fixed; I probably could have used
          "index.txt" too. I haven't done this, because I rarely validate that
          way, but you can tell Mozilla that .php is a plain-text file somewhere
          in her settings.

          I don't know why I think Mozilla is a girl.
          --
          Looks like more of Texas to me.
          .... Arizona, where the nights are warm and the roads are straight.

          Comment

          Working...