Page 1 of 1

Multiple DOCTYPE Issue with Page Title

Posted: Wed Oct 13, 2010 5:19 pm
by Uncle_Frank
Hello all! :D

First post here, thank you for letting me join this Forum. Looks like a great resource for my new interest in PHP development.

Anyways, here is my issue that I need help with:

I have a .PHP page that connects to a MySQL database, then has an HTML section for display. I have an issue with the page title.

When I load in FF or IE, the page title is "Untitled Document". When I check the page source I get this:

------------
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>This should be the correct title</title>
</head>
<body>
</body>
</html>
------------

Now, in my HTML file, I obviously have not put the two DOCTYPES. I've just have the bottom one. The first DOCTYPE is added when the page is loaded.

Any idea what I am doing wrong? This is driving me nuts! :banghead:

The only PHP code that is listed before the HTML code is:

------------
<?php
include("Database_Connect.php");
?>
------------

Website is hosted @ 1and1.com, PHP version is 5 I believe.


Thanks

James

Re: Multiple DOCTYPE Issue with Page Title

Posted: Wed Oct 13, 2010 6:10 pm
by twinedev
what is in Database_Connect.php (post it here but strip out your login credentials (host,username,password)

-Greg

Re: Multiple DOCTYPE Issue with Page Title

Posted: Wed Oct 13, 2010 6:31 pm
by Uncle_Frank
Here is what is in this page:

-------------

<?php
//Connect to Database
$dbh=mysql_connect("database", "user", "pw") or die('You suck. No connection because: ' .mysql_error());
mysql_select_db("database");
//echo 'Connection successful';
//mysql_close($link);

?>


<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

-------------

I bet it is because I have the HTML there...let me remove and then retry.

James

Re: Multiple DOCTYPE Issue with Page Title

Posted: Wed Oct 13, 2010 6:32 pm
by Uncle_Frank
Yahoo!

Who knew it could be so easy. Thank you so much for asking what was in that file!

That totally fixed the issue. Not its not printing that extra bit of HTML when it makes the database connection!


Cheers!

James