PHP includes?


#1

I am moving my hosting from anothe host to DH. I have MovableType installed and use a MTinclude to pull in a sidebar that also pulls in a php include.

On the old host I used to use:

<?php require("/home/#USER#/public_html/bookmarks/bookmarks.html"); ?>

However that does not work. So I checked the wiki and have tried this instead:

<?php include($_SERVER['DOCUMENT_ROOT']."/bookmarks/bookmarks.html"); ?>

This is not processing once the MTinclude is pulled into the page.

What is going on? It seems as though the PHP is not even processing.

Thanks for any help.


#2

What’s the name of the file? You really don’t give any details to allow any debugging.


yerba# rm -rf /etc
yerba#


#3

The pulls in a module cleverly named “navmodule”.

Inside of “navmodule” I had this:

<?php require("/home/#USER#/public_html/bookmarks/bookmarks.html"); ?>

Calling a file named “bookmarks.html” which is simply a bit of html that is generated from another blog and I want it included in the sidebar along with my other sidebar content.

The DOES get pulled in no problem. However the PHP is not being seen or processed as when I view source on the page the PHP is still there and not rendering the include.

So I checked the wiki and have tried this instead:

<?php include($_SERVER['DOCUMENT_ROOT']."/bookmarks/bookmarks.html"); ?>

This still behaves the same as my previous code.
I have also tried using a .php extension on my included file as well.

This is being called into a page that is “index.html” does DH have php turned off for anything but a PHP extension?
and if so can I switch that configuration on my domain so it will run inside .html files?

Or am I dealing with another issue here?

Thanks


#4

And there is your problem. .html are static HTML files. You have to have them named .php for them to be parsed by the PHP parser.

It can be done, but I wouldn’t advise that. It adds unnessary load on the server when all you want is a static HTML file.

To accomplish what you want, add this to the .htaccess file. However, like I said, you do NOT want to do this as it will cause an increased load on the server (increased load == SLOW website):
Action php5 /cgi-system/php5.cgi
AddHandler php5 .html

Like I said before, and I stress this again, HTML files are for static files. They are your quick load files that do NOT get parsed by anything (although some people will parse them through SSIs). They are NOT meant to be used for PHP parsing. That’s what PHP files are for (.php).


yerba# rm -rf /etc
yerba#


#5

Ok - thanks for the advice.

If I have a couple of static includes to get pulled into a page, what would be a better way of handling them - rather than parsing the PHP inside of the html file?

Thanks again.


#6

SSIs, Server Side Include:


yerba# rm -rf /etc
yerba#


#7

That did it!

Thanks!