• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

PHP Server Side Includes in WinXP Home?

RSLancastr

www.StopSylvia.com
Joined
Sep 7, 2001
Messages
17,135
Location
Salem, Oregon
I am currently trying to use SSI for inclusions of standard headers, footers, and other such things in HTML.

The web site will be running in an Apache/PHP environment.

The only way I know at this point is to use the PHP include statement, as in:

<? include 'filename.ext'; ?>

This works, but it is a hassle, because I am developing the site in a WinXP Home Edition environment.

It appears that the server only processes the includes if the file containing the include statement has a .php extension. They are ignored if the file has a .htm, .html, or .shtml extension.

But, I can't get IE to load a .php file in my development environment.

Do I need to load IIS in order to get PHP to work in my dev environment? If so, that's a problem, as Microsoft does not support it on XP Home. There are pages which show you how to load it, but they all seem to recommend not doing it.

So, any suggestions? Is there an easier way to do SSI, which would be supported by both my development and hosting environments?
 
For SSI, you should be able to use the standard #INCLUDE command. As follows:

1) Change the extension of the base HTML page into which file(s) will be included to be .SHTML. This forces the webserver to "process" them appropriately.

2) Use the following code in your HTML where you want the file included:

<!--#include file="some-included-file.htm" -->

Your included file can also have includes. You can include more than one file in this page. You can include VB or PHP code. The included file can be a code fragment. There are variations on this, but you get the idea. Look it up! It's good for adding chunks of common code to many pages, while allowing you to edit it in one place.
 
I am currently trying to use SSI for inclusions of standard headers, footers, and other such things in HTML.

The web site will be running in an Apache/PHP environment.

The only way I know at this point is to use the PHP include statement, as in:

<? include 'filename.ext'; ?>

This works, but it is a hassle, because I am developing the site in a WinXP Home Edition environment.

I suggest you look into XAMPP. It'll make life much easier. You can do your development in an environment much more like your deployment site.
 
SSI (Server Side Includes" are just what the name says. They are included on the server side. IE hasn't got anything to do with causing them to be included. If you are just opening the files in IE from your local hard drive, then SSI cannot work by definition - you have no web server to do the includes.

For what you are trying to do, you must have a web server locally for your local tests. Since you will be deploying to Apache/PHP, you should go XAMPP rather than IIS.

Take Zep's notes on SSI to heart. He's telling you the proper way to do your includes.
 
Zep, Mort, thanks!

<!--#include file="some-included-file.htm" -->
What is the difference between this and:

<!--#include virtual="some-included-file.htm" -->

... which I see suggested elsewhere?

I suggest you look into XAMPP.
Done, thanks! Now I just need to figure out how to put my web site into the XAMPP server. I was hoping it was just a matter of creating a folder in the htdocs folder, but that doesn't seem to be it.

Again, thanks to you both!
 
Done, thanks! Now I just need to figure out how to put my web site into the XAMPP server. I was hoping it was just a matter of creating a folder in the htdocs folder, but that doesn't seem to be it.

Again, thanks to you both!
That's the way I have mine set up. Is your XAMPP folder set up in your root drive? The path should be: C/xampp/htdocs/your_website/
 
That's the way I have mine set up. Is your XAMPP folder set up in your root drive? The path should be: C/xampp/htdocs/your_website/
Yes, after my last post, I found that I had misspelled my website's folder's name. :o

Well, back to the fun!
 
That's the way I have mine set up. Is your XAMPP folder set up in your root drive? The path should be: C/xampp/htdocs/your_website/
Sophia8, how do I set up XAMPP so that the folder containing my web site is treated as the root folder on the server?

In other words, if I reference "/images/mypic.jpg" from a page of my site, I want it to find (given your example above) C/xampp/htdocs/your_website/images/mypic.jpg.

I haven't found the way to set this as yet.

Thanks,

-RSL
 
Zep, Mort, thanks!

What is the difference between this and:

<!--#include virtual="some-included-file.htm" -->

... which I see suggested elsewhere?

Done, thanks! Now I just need to figure out how to put my web site into the XAMPP server. I was hoping it was just a matter of creating a folder in the htdocs folder, but that doesn't seem to be it.

Again, thanks to you both!
INCLUDE FILE and INCLUDE VIRTUAL are actually similar, but not quiet interchangeable. Here's a short tutorial from Apache that explains it better than I can!
 

Back
Top Bottom