We help IT Professionals succeed at work.

PHP MySQL

assaultkitty
assaultkitty asked
on
I am having problems validating this file.  Can you help me?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Code Blocks</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<?php
echo "This text is displayed using standard PHP script
delimiters.";
?>
</p>
</body>
</html>
Comment
Watch Question

What kind of problems are you having?  What error messages are you getting, etc.
If you change the meta line to this (add the /> to the end)

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

it will pass the W3C validator.
Keith BrownAWS System Administrator
CERTIFIED EXPERT

Commented:
In the title, you mention MySQL, but your code has nothing to do with MySQL.

In your code, you are going for strict XHTML, but did not close the meta tag. If the tag is for an object that has no ordinary ending tag, you need to have a / at the end of the tag to show it is done. So, <br> in regular HTML becomes <br /> in XHTML.

Also, one quirk I noticed is that you had the echo wrap around, which can cause issues at times.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Code Blocks</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>
<?php
echo "This text is displayed using standard PHP script delimiters.";
?>
</p>
</body>
</html>

Open in new window

Author

Commented:
This is the error message I am getting from the validator.w3.org.  I saved the file as a php file instead of html because it does contain a php file in it,  According to the text, I must save as a php but the validator gives the following error message (when I save it as a HTML file it validates)  Can any one explain?


    Error

    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 Content-Type header is sent by your web server (or web browser if you use the file upload interface) and depends on its configuration. Commonly, web servers will have a mapping of filename extensions (such as ".html") to MIME Content-Type values (such as text/html).

    That you received this message can mean that your server is not configured correctly, that your file does not have the correct filename extension, or that you are attempting to validate a file type that we do not support yet. In the latter case you should let us know that you need us to support that content type (please include all relevant details, including the URL to the standards document defining the content type) using the instructions on the Feedback Page.
Keith BrownAWS System Administrator
CERTIFIED EXPERT

Commented:
How are you passing it to the validator? Are you giving it your URL, are you uploading the file, or what?

Also, the w3 validator only handles html files if you do a file upload. If it doesn't have a .html extension, then it will throw a fit. Either paste the code in, or give it a URL when validating code with PHP.
Keith BrownAWS System Administrator
CERTIFIED EXPERT

Commented:
Any luck yet, kitty?
Most Valuable Expert 2011
Top Expert 2016

Commented:
This validates:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.laprbass.com%2FRAY_temp_assaultkitty.php&charset=%28detect+automatically%29&doctype=Inline&group=0

The script is located at:
http://www.laprbass.com/RAY_temp_assaultkitty.php

But that said, why not just use HTML5?  It is much more relaxed and is widely supported.  Just a thought, ~Ray
<?php // RAY_temp_assaultkitty.php
error_reporting(E_ALL);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Code Blocks</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>
<?php
echo "This text is displayed using standard PHP script
delimiters.";
?>
</p>
</body>
</html>

Open in new window

Author

Commented:
I did not get the correct answer.  The teacher helped me with this one.

Author

Commented:
Well, according to the instructor.  To validate a PHP file in the validator you can paste the program into it and then validate.  This process works for me.  Thank you.

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for assaultkitty's comment http:/Q_27429844.html#37237264

for the following reason:

This is the solution.
AWS System Administrator
CERTIFIED EXPERT
Commented:
Assault kitty, I already told you that, a month ago.

This is what I said on 11/4

Also, the w3 validator only handles html files if you do a file upload. If it doesn't have a .html extension, then it will throw a fit. Either paste the code in, or give it a URL when validating code with PHP.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.