Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php include in template page

wont work



10:04 am on May 23, 2008 (gmt 0)

10+ Year Member

I downloaded a free link directory script and modified the template
layout for my site. the script is in a folder e.g www.mysite.com/dir/

and I want to include the footer for all the pages in the /dir/ folder

I tried adding a include e.g <?php include("includes/footer.php"); ?>

and it wont show up but when I view source from the browser i can see the include code on the page (<?php include("includes/footer.php"); ?>)

I thought that you cant see php code if you view source from the browser.

does that mean there is somthing else to do to use a php include?



11:31 am on May 23, 2008 (gmt 0)

10+ Year Member

It sounds like the page that you've inserted the PHP code into isn't getting parsed. Does it have the .php extension?


11:57 am on May 23, 2008 (gmt 0)

10+ Year Member

the page has a php extention e.g template.php and from what I understand whatever I change on that page shows up on the index.php page
only the include does not work. about not being parsed what do you do for that? as I said before when i view the pages source code from the browser it shows the include code. is that what you mean by not being parsed?



12:28 pm on May 23, 2008 (gmt 0)

10+ Year Member

yes, definetely not parsed.

Put a <?php echo "hello mom";?> at the top of the page to confirm and see if it shows when you view it or if the code just sits there.

[edited by: Pico_Train at 12:29 pm (utc) on May 23, 2008]


12:47 pm on May 23, 2008 (gmt 0)

10+ Year Member

well I tried <?php echo "hello mom";?> and it didn't show up on the page

but I could see it when I viewed the source code. so if it wont parse how do you fix that?



12:57 pm on May 23, 2008 (gmt 0)

5+ Year Member

What is the file name? it should be something like "filename.php"

Also... your server is set up to use PHP.. correct?


1:19 pm on May 23, 2008 (gmt 0)

10+ Year Member

the file is <?php include("includes/footer.php"); ?>

and I am calling it from a folder e.g www.mysite.com/includes/footer.php

and I want the contents of footer.php to show up on my page which is in


the thing is that the /dir/index.php page calls the layout of the page from the template.php page which I placed the include file in so that it would show up on the /dir/index.php page if i add the include directly to the /dir/index.php page it works.

any ideas?


1:50 pm on May 23, 2008 (gmt 0)

10+ Year Member

I think...
[its more convoluted than I originally thought...]

...maybe try...

<?php include("../includes/footer.php"); ?>


2:21 pm on May 23, 2008 (gmt 0)

5+ Year Member

Or...Don't know exactly how you have things set up, but couldn't you just put your footer info in the "template.php" file and skip the footer.php include altogether?


3:20 pm on May 23, 2008 (gmt 0)

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Your problem is almost certainly due to the fact that the template is called by a class
that calls a bunch of "sections"
so figure out if there is a class and what the class calls for.
you might find something like:

$content_page_name .= '';
include "../../includes/page_name.inc.php";
$page->SetParameter("PAGE_NAME",$content_page_name );

and each includes (you will need to create yours)
might look like this:
$db = new MySQL_Db;
$db->connect($host, $un, $pw);
$result = $db->query("
SELECT main_content
FROM #*$!#*$!
while($new_content= $db->fetch_array($result))
$content_main_content.= $new_content['main_content'];


9:48 pm on May 23, 2008 (gmt 0)

10+ Year Member

I think henry is right, I just got an email from the guy that wrote the script & he said that I have to place the include in the index.php file & not the template.php cause the index file calls each part of the directory script e.g categories ect..

only thing is that the include shows up on the page when put in the index file but not in the position that i want it. he didn't mention how to position it.

anyway thanks guys!


Featured Threads

Hot Threads This Week

Hot Threads This Month