Tino03 Posted December 21, 2008 Share Posted December 21, 2008 I'm experiencing some trouble with it.I have two files which I include in every page, namely "top.php" and "bottom.php". These files have the layout of the site stored in them, from after the <body> tag until the content area, and from after the content area to right before the </body> tag.So that means my pages look like this. <html><head>All head stuff</head><body><?php include("top.php"); ?>CONTENT AREA<?php include("bottom.php"); ?></body></html> That's obviously just a simplified code. The problem is, for the main page (index.php), this works fine. But when I try to set up another page, it suddenly won't work anymore, even though I use exactly the same code.Any ideas what could cause this? Link to comment Share on other sites More sharing options...
Anman Posted December 21, 2008 Share Posted December 21, 2008 Is that other page you're trying to set up in the same folder as the main page?Are you making sure to use .php file extension instead of .html?Are you running this locally or on a host elsewhere? Link to comment Share on other sites More sharing options...
Tino03 Posted December 21, 2008 Author Share Posted December 21, 2008 I figured it being in a different folder would cause the problem, and that was it.Though, how can I include "top.php" and "bottom.php" if the page I want to include those files in are in a different folder? Or is that impossible? Link to comment Share on other sites More sharing options...
jeffman Posted December 21, 2008 Share Posted December 21, 2008 Assuming the folders are at the same level as index.php, simply construct a path:include ('folder/top.php');If index.php is itself in a folder, you could still use a relative path:include ('../folder/top.php'); # TWO DOTS MEAN 'GO UP ONE LEVEL'Or it may be easier to start at the root level and work down:include ('/folder/top.php'); # INITIAL SLASH MEANS START FROM ROOT Designers often create files that might be imported from anywhere in the directory tree. Like if you wanted ALL files for a large company to include the same footer. That's a good argument for following my third example. Link to comment Share on other sites More sharing options...
Tino03 Posted December 21, 2008 Author Share Posted December 21, 2008 I got it to work now, using the "go up one level" method. Thanks. Your help is much appreciated Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.