Link to home
Start Free TrialLog in
Avatar of assaultkitty
assaultkitty

asked on

PHP MySQL

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>
Avatar of Scott Madeira
Scott Madeira
Flag of United States of America image

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.
Avatar of Keith Brown
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

Avatar of assaultkitty
assaultkitty

ASKER

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.
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.
Any luck yet, kitty?
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

I did not get the correct answer.  The teacher helped me with this one.
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Keith Brown
Keith Brown
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial