By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 ...

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.**


The solution is very easy. Thank you to Michael Fuhr for the tip!
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.


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) ==

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Antho <pr**********@coz.spam.sux> writes:
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.**


The solution is very easy. Thank you to Michael Fuhr for the tip!


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.
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.


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.


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.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2

P: n/a
Posted by Michael Fuhr on Tue, 18 Nov 2003 20:44:36 -0700:
Antho <pr**********@coz.spam.sux> writes:
<snipped stuff>
The solution is very easy. Thank you to Michael Fuhr for the tip!


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.


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) ==

Jul 17 '05 #3

P: n/a
Antho <pr**********@coz.spam.sux> writes:
Posted by Michael Fuhr on Tue, 18 Nov 2003 20:44:36 -0700:
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.


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".


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
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #4

P: n/a
In article <pa****************************@coz.spam.sux>,
Antho <pr**********@coz.spam.sux> 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.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.