View Full Version : Cannot Get Basic Include to Work (Dreamweaver)

01-09-2012, 05:21 PM
I understand the concept behind "includes" and have done a lot of poking around for how to execute. However, I still cannot get my first attempt at one to work.

I'm on Mac OX 10.6.8, Dreamweaver CS5

I've installed MAMP locally and know it is working properly as the tests have run fine and the MAMP server page states success.

The code I'm using for placing the include in my main file is:
<?php include("includes/Lorenz_Hero.html"); ?>

The PHP badge does appear in code view mode

since it's an HTML file, I've seen that you are to add:
AddType application/x-httpd-php .php .html
AddHandler application/x-httpd-php5 .html .htm .php

to the htaccess file located:
I did this (should they be preceded by a # ?)

My two files are, and reside as follows:

Is there a bit of code I need to add to file being called in the include?

Obviously I'm missing something. I have spent a lot of time looking for an answer and just cannot find one. I hope the above information is clear and someone can point me in the right direction for an answer, or provide it here.

Thanks in advance for any help.

01-10-2012, 12:58 AM
i would recomend using php extension to your pages as it will just become tricky perhaps when you go truly live finding a server that yu can modify, secondly you could try html includes but you may come across the same problems i mentioned above.

if you really still want though you can try editing

<IfModule mime_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .txt

and .htaccess

<FilesMatch "\.(html|htm|txt)$">
SetHandler application/x-httpd-php

01-10-2012, 01:23 AM
Thank you...I will try your html advice.

But doing as you primarily advise (which I'd prefer), my question would be:
Can I simply change the file extension from .html to .php (which I had tried), or
do I need to re-format before doing that?
I have looked into this and just cannot find a sample of an HTML converted to
a PHP file to use as a guide.

Thank you again!

01-10-2012, 01:48 AM
changing php should work. You probably have but is php started as a service

if you make a page.php and put

and call it in a bowser what do you get?

01-10-2012, 02:14 PM
Also remember that you don't need to parse a html file as php to include it in a php file.

01-10-2012, 03:16 PM
Well, I'm sorry, but I can't get this to work or simply don't understand the direction (as I said, this is very new to me). I've attached zip file with the test files (which I have placed: Applications/MAMP/htdocs/). If you have time or care to peek at this, let me know where I'm going wrong.

Thanks again for your time and efforts!

01-10-2012, 04:58 PM
I'd save all your pages as .php if you are using includes.

Your main file header-test.html

Isn't a full html page it only contains a DIV this should be a full page see below.

Not sure why this DIV needs an ID and well as a Class but ID's shouldn't have a # in front of them. Only use the # when you are selecting them via CSS.

So in your header-test.html rename to .php and use the following code.

<!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" dir="ltr" lang="en-US">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/Lorenz2.css" rel="stylesheet" type="text/css">
<title>A Doc</title>



<div class="menuMain" id="menuMain">

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

</div><!-- end menuMain -->


Also, any css should be in the main file not in the included file. Again see my code.

Finally remove the php info code from your header.php file.