include problem

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
itsdavidp
Forum Newbie
Posts: 1
Joined: Thu Jul 01, 2004 3:27 pm

include problem

Post by itsdavidp »

I am trying to revamp my webpage so that the menu is loaded from another file, and therefore I do not have to rewrite the menu for every html file in my website.

Basically I tried copy and pasting my HTML menu out of the html file and into a new html file. I then used php and said:

Code: Select all

<?php 

include 'menu.html'; 

?>
However, it did not work properly.

I then tried moving everything in menu.html into menu.php, and I just made menu.php a series of print statements, so basically it would have the same effect as just displaying normal html code, and then change the include menu.html to be an include of menu.php, however, that did not work either.

The code can in its entirety can be viewed here:

http://students.cs.byu.edu/~dprucs/index.html
http://students.cs.byu.edu/~dprucs/menu.html
http://students.cs.byu.edu/~dprucs/menu.php

What do I seem to be doing wrong?

P.S. menu.html and menu.php both work correctly when used by themselves, however they do not work correctly when included in index.html
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

are html files set to be parsed by php?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

For his first example, it wouldn't really matter. He just included it, so it should print everything to the screen.

Code: Select all

<?php include("filename.html"); ?>
try that (replacing filename with.. the filename :P )
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Also, are you getting some error message? Post them here if you get any.

-- Scorphus

p.s. I tried to open http://students.cs.byu.edu/~dprucs/menu.html what returned an Error 404 page.
Post Reply