Validating XHTML

Good evening,

I always make sure my HTML websites are valid HTML/CSS using W3C's validator. I'm trying to do the same for my PHP pages, but after I fix all the errors I'm left with this:


The MIME Media Type (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode.


What does this mean? I'm very new to the world of PHP, but I would presume from the message something is wrong in my doctype. This is what it looks like at the moment:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head>
<title>Page title</title>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
...

Is that correct for a page that uses PHP and MySQL?
 
How are you trying to validate it? Are you copying and pasting your pages into the text box or giving the validator the url for your site?

I don't see a problem with the heading, try taking out your meta http-equiv tag, PHP should set the content type to text/html by default.
 
Thank The Cheese said:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head>
<title>Page title</title>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

Is that correct for a page that uses PHP and MySQL?

XHTML tags must be done in lower case and must be ended (trailing slash on certain tags) properly. Your meta tag (which is required for the HTML to be valid, regardless of what PHP may set) is probably what's causing the issue, since it's in upper case and not ended properly. Also change the doctype string (this should be cased as shown) to what's below (the link address to the DTD seems to be wrong).

Code:
<!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>
	<title>Something Here</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
 
thanx guys -- that did the trick mdnky :D

I have to remember to put the "/>" at the end of BR and IMG etc tags. I keep forgetting because I'm so used to stright HTML.

Well, that's my PHP-related question for this week. Sorry to post all these questions. I'm learning a lot, but as soon as I think I know everything I need to about PHP, something like this comes along. This forum is invaluable! :)

thanks again
 
Back
Top