Forum Moderators: coopster

Message Too Old, No Replies

header include problems!

getting the title tag to work

         

zair

9:28 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



I am new to php, so this is probably a simple problem to fix, but I can't figure it out for the life of me. I'm using a simple php include to put a header and a footer on my page. It works just fine except that I can't get a title to show up on any page unless I put the <title>Whatever</title> tag on the MAIN page, rather than in the header file with all the rest of the header stuff!

One very strange thing to me is that when I do put a title in the <head> </head> on my header page, it gets completely ignored. The title tag doesn't even show up in the source code when I validate at the W3 validator. Also, the validator says my <head> tag is ending prematurely, but I can find nothing at all outside of it that would need to go in!

Anyway, the only way I can get a title to show up is if I put it outside of the header file, in the main file. But if I do that, then when the file gets read, it sticks the title up on top, above the doctype, which causes the doctype to be ignored and creates a great big mess of validation errors.

I'd really like for this page to validate, if at all possible. I mean, it LOOKS fine to me putting the title in the main page rather than the header, but I don't think it reads the doctype anymore.

I can sticky a link to the page if someone wants to see. It would probably help.

Thanks, and I hope that made at least a little sense!
-Tobyn

Philosopher

9:32 pm on Aug 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sure...sticky me a link and I'll take a look. You can also post some of the code here as seeing the actual code you have in your header would help as well.

zair

10:39 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



Here's the header file...

<!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" xml:lang="en" >
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="robots" content="all" />

<title>Title here</title>

<script type="text/javascript" src="test/dynacrumbs.js"></script>

<style type="text/css" media="all">
@import "test/vu.css";
</style>
</head>

<body>

<div id="container2">
<div id="top">
<img src="images/welcome4.gif" alt="Welcome to the Viking Union/Student Administration" id="welcomeimg" />
<a href="#"><img src="images/room-reservations.gif" alt="For information on room reservations at the VU, click here!" id="reservationimg" /></a>
</div>
<div id="leftcontent2">
<div id="linkdiv2">
<hr id="hr" />
<div class="link"><a href="http://www.google.com">Today's Events</a></div>
<div class="link"><a href="http://www.yahoo.com">A &#38; E Information</a></div>
<div class="link"><a href="http://www.lycos.com">Recreation Programs</a></div>
<div class="link"><a href="http://www.lycos.com">AS Programs and Organizations</a></div>
<div class="link"><a href="http://www.lycos.com">Services</a></div>
<!-- <div class="link"><a href="http://www.lycos.com">Room Reservations</a></div> -->
<div class="link"><a href="http://www.lycos.com">Fee Schedules</a></div>
<div class="link"><a href="http://www.lycos.com">Dining</a></div>
<div class="link"><a href="http://www.lycos.com">FAQs</a></div>
<div class="link"><a href="http://www.lycos.com">Staff Directories</a></div>
<div class="link"><a href="http://www.lycos.com">Policies</a></div>
<div class="link"><a href="http://www.lycos.com">Associated Students</a></div>
</div>
<div id="vumain2"></div>
</div>

<div id="rightcontent2">
<div id="test">
<div id="box1">
<img src="images/whats-new.gif" id="whatsnew" alt="What's New in the VU?" />
<div id="divider"></div>
<a href="#"><img src="images/housing-registry.gif" id="housingregistry" alt="Off-Campus Housing Registry"/></a>
<a href="#"><img src="images/rider-driver.gif" id="riderdriver" alt="Need a ride? Want to offer a ride? Click here!"/></a>
</div>

<div id="box2">
<a href="http://www.somesite.edu"><img src="images/somesite.gif" id="somesite2" alt="Visit the University Homepage" /></a>
</div>
</div>

<!-- <div id="right2">
my oh my
</div> -->

<!-- //END header file -->

and then the opening lines of my main page...

<?include "config.php";
include "$union_path/header.php";?>

at one point in time I had a $title="Arts and Entertainment"; in there, but it wasn't showing up either, even when I had the echo in the title tag of the header...

[edited by: jatar_k at 11:10 pm (utc) on Aug. 10, 2004]
[edit reason] generalized [/edit]

Philosopher

4:47 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm...ok...so the code you pasted here is the exact code you are using on the example page URL you sent me (with the exception of the url generalization per the TOS)? And the only bit of code that is NOT printing to the page is the title tags?

zair

6:28 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



that is correct. The code I posted on here was the exact code, and the page you saw is what it ends up like. You can see in the page I sent you that the title tag is indeed nowhere to be seen! Makes no sense to me... :)

Thanks again,
Tobyn

EDIT: I've checked it in both IE and Firefox, and they both don't read the title tag.

Also, the comment tags show exactly where my header and footer files end and begin.

Philosopher

7:50 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm...that is indeed very strange.

The first thing that comes to mind is that maybe you have two different versions of header.php and you are making changes to one but it is the other that is being included?

I know that sounds strange but I have done that very thing...uploaded a page to the wrong folder and couldn't for the life of me figure out why my changes weren't being reflected.

I just can't see any reason why that one particular line of code woulnd't print to the browser screen.

Could the above be a possibility?

zair

8:02 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



Ha ha ha! That was it, indeed. I had made a copy of the header to the root directory, and was calling that one, as opposed to the one in the test folder.

Now it works like a charm! I even got it to echo the title from each individual page! Now it validates as XHTML 1.0 strict, and it works just how I wanted it to.

Thanks a bunch! :)
-Tobyn

Philosopher

8:09 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL...it's always the little things isn't it?

zair

8:30 pm on Aug 11, 2004 (gmt 0)

10+ Year Member



hehehe, always the little things!