Multiple DOCTYPE Issue with Page Title

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Uncle_Frank
Forum Newbie
Posts: 5
Joined: Wed Oct 13, 2010 5:09 pm

Multiple DOCTYPE Issue with Page Title

Post 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
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Multiple DOCTYPE Issue with Page Title

Post by twinedev »

what is in Database_Connect.php (post it here but strip out your login credentials (host,username,password)

-Greg
Uncle_Frank
Forum Newbie
Posts: 5
Joined: Wed Oct 13, 2010 5:09 pm

Re: Multiple DOCTYPE Issue with Page Title

Post 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
Uncle_Frank
Forum Newbie
Posts: 5
Joined: Wed Oct 13, 2010 5:09 pm

Re: Multiple DOCTYPE Issue with Page Title

Post 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
Post Reply