0

This is my first post here as I am a student that is just learning (getting dangerous with) HTML but I have a problem that I understand could be helped with php coding.
The reason I want to use this is to cut down on the amount of coding on each page and when changes need to be done on either 'header' or 'footer' it could be done on just the one page instead of working on all 50 pages.
The site I am working on is . I want to put this php code on each page of the site:

[B]<div>
<?php include("header.php"); ?>
</div>[/B]

The text in this

<div>

is:

[B]<table>
    <tr>
    <td>
    <img src="images/cornerlizard.jpg" width="150" height="110" alt="Little Lizard" /> 
    </td>
    <td width="50px"></td>
    <td width="75%">
    <center><h2><font face="Lucida Sans Unicode, Lucida Grande, sans-serif" color="white">Terri the Lizard Lady<br />
    The finest in<br/>Rhacodactylus Geckos<br />since 2003</font></h2></center>
    </td>
    <td>
    <img src="images/gecko-02.jpg" width="150" height="110" alt="Little Lizard" />
    </td>
    </tr>
</table>[/B]

How do I make the header.php page so that this works?
I figure once I have this figured out I can do the same with the footer for each page.
I went on a site that had this and here is what I found:

[B]<html>
<body>
<?php include("header.php"); ?>
</body>
</html>[/B]

I tried this but nothing happened.
----
One more question:
Will this idea also work with a java script that I use for the menu?
My E-Mail address is: dennis [at] mia [dot] net

2
Contributors
14
Replies
17
Views
5 Years
Discussion Span
Last Post by Zagga
0

Hi daitken,
Once you have php working correctly, the include statement will add everything that is in header.php inside you'd <div> tags, just as if you had written the code in there yourself. This includes any php, HTML and Javacript.

The thing you have to remember is that any page that contains <php ?> tags needs to be saved as a PHP file itself, not an HTML file.

Edited by Zagga: n/a

0

I am working in Dreamweaver right now and I have it on 'Live View'
Everything else comes up (all the html) except the php header itself.
Does this mean that it will only work once it is FTP to the host to be able to see it work?
Does the index.html need to be changed to index.php?
I have the header.php up already and it still doesn't show anything.

0

Hi again,

Yes, index.html needs to be renamed index.php

You will only be able to see what php does if it is run on a server (it is a server side language), This means you either have to upload it to your webhost or you can install a server on your pc. Have a look into XAMPP for an easy to install and use server that has PHP included.

0

I will change the name right now, FTP and check it out.
BRB

0

I uploaded all the files again and it doesn't work.
Do I have the right code on the php page?
It has the Greeting then it comes up with this line:

Parse error: syntax error, unexpected '<' in /home/terriliz/public_html/test/header.php on line 4

Here is the fisrt section of the page:

<!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=UTF-8" />
<title>Home of Terri the Lizard Lady</title>
 
<link rel="stylesheet" type="text/css" href="textstyle.css" />
</head>

<body bgcolor="#9932CC">
<br />

<br />

<center>
<h1>Welcome to my home page!</h1>
<div>
<?php include("header.php"); ?>
</div>

<br />

Please keep in mind that I am a student that is just use to html coding at this point.

0

The message is indicating that there is an error in the header.php file (usually on the line BEFORE the one it states).
Could you post the code from header.php please?

0

This is the entire page header.php

<html>
<body>
<?php
    <table>
	<tr>
    <td>
  	<img src="images/cornerlizard.jpg" width="150" height="110" alt="Little Lizard" /> 
  	</td>
    <td width="50px"></td>
    <td width="75%">
    <center><h2><font face="Lucida Sans Unicode, Lucida Grande, sans-serif" color="white">Terri the Lizard Lady<br />
    The finest in<br/>Rhacodactylus Geckos<br />since 2003</font></h2></center>
    </td>
    <td>
    <img src="images/gecko-02.jpg" width="150" height="110" alt="Little Lizard" />
    </td>
    </tr>
	</table>
?>
</body></html>
0

Ok, the <?php tag tells the interpreter (the engine that actually runs the php for you) that there is some PHP code coming up instead of HTML. You haven't actually got any PHP code in here so you can just remove line 3 altogether. You also need to remove line 19 as the ?> tag tells the interpreter that the PHP section of code has finished.

Next, when this file is included in index.php, you will have 2 <html> tags, so you need to remove this (and the closing </html> tag) from header.php.

Then you should be all set :)

(as a note, the error message was telling you that it didn't recognize <table> as valid PHP code because it was expecting to see PHP tags)

Edited by Zagga: n/a

0

Man I owe you big time!
I actually have learned a lot by your explanations also.
I am a 58 year old return to college student at Blackhawk Technical College in Janesville, WI.
Fall semester I took business but switched to the IT program this semester because I use to create web sites in (I know you are going to cringe) Frontpage.
Again I am very grateful and I owe you dinner if you live close by!

Dennis J. Aitken
http://www.variousphotography.com
Photographer/Writer
BTC Flyer|Online

0

Sorry, the same goes for the <body> tags too, you need to remove these from header.php

0

I'm 41 and remember Frontpage well :)

Glad I managed to help and I'm sure you will get lots of help from the members here. I actually got into PHP for the very same reason you did, to include a header and footer. Once you start learning about PHP you will wonder how you ever did without it.

0

In the css it takes the div and ... well look at this page and you will understand.
http://terri-lizardlady.com/test/ttll_about.html

I tried to put div above and below the php code on index & it didn't show up so I tried it on the header.php and it didn't show up either.
Do I need to add this on the header.php?:

div {
	border:2px solid black; 
	alignment-adjust:center; 
	width:80%; 
	text-decoration:none;
	}

div {
	border-radius:25px;
	}
0

Never mind.
I did it on the index.php page and it works!
Thanks again!
Going to bed now.
Get up at 05:00 for school!

0

You don't need to add the CSS rules to header.php as it will use the same rules as the page it is included in (index.php).

You need to add the same class to the div as all the other divs to make them all look the same. Add class="content" to the div that holds the header (line 18 of index.php) and the one that holds the footer (line 20).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.