# PHP/SSI Includes

**URL:** <https://forum.kirupa.com/t/php-ssi-includes/9793>\
**Category:** programming\
**Created:** [December 18, 2002, 6:49pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793 "2002-12-18T18:49:29Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustSara](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@JustSara](https://forum.kirupa.com/u/JustSara)\
**Post date:** [December 18, 2002, 6:49pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/1 "2002-12-18T18:49:29Z")

</div>

Lord help us all I’ve been put in charge of the website! lol  
I am trying to get either SSI includes or PHP includes to work on my site. I’m starting small with the date…

Here’s my problem. I know PHP is installed on the server because I have submit form on there that I made with Flash and use PHP to run.

On my index page I tried a PHP include:

```php
<?php include('date.html'); ?>

```

and I tried an SSI

```php
<!--#echo var="DATE_LOCAL" -->

```

I can’t get the PHP include to work at all and the SSI include works if I change the file name to index.shtml but when I do that I get a listing of all files on my site instead of the index page.

My website is [www.soacorp.com](http://www.soacorp.com) if that helps at all.  
Much thanks  
JustSara

[edit] by lostinbeta: to show code [/edit]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 18, 2002, 6:57pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/2 "2002-12-18T18:57:47Z")

</div>

Well just to double check…

Your PHP includes should obviously be in a page that has the extension .php.

And the include tag should look something like this…

```php
<? include("yourFile.txt") ?>

```

And as for your SSI includes… I don’t see why it would list all your files. To me that doesn’t seem like something an include could do. Could be something else in your file that is conflicting with the .shtml extention I guess.

If that link was supposed to be to the page where the error with the .shtml extension occurs, I don’t see any problem on there :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 18, 2002, 7:11pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/3 "2002-12-18T19:11:15Z")

</div>

Heh, I had the actual code in my original message but it didn’t show it. You’re absolutely right, to use the PHP file my page should have been index.php but when I changed it to that the include still won’t show up. :’’-(

The SSI include isn’t what is showing all my files. When I changed index.htm to index.shtm the browser didn’t see it as the ‘index’ page at all and instead listed the entire directory.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 18, 2002, 7:14pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/4 "2002-12-18T19:14:00Z")

</div>

With the PHP… are you 100% positive that the files are linked directly.

I know if you are using programs such as Dreamweaver for Frontpage they have a habit of writing the full URL of the file on your hard drive instead of the URL it would be on in the server.

As for the SSI… that is friggin weird. I know some servers allow you to use SSI while having the extention .html, but others force you to have the extention .shtml for the SSI to work. But if .shtml doesn’t work, your page will still load, it just won’t show the includes.

Did you talk to the your host or the server tech support?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 18, 2002, 7:17pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/5 "2002-12-18T19:17:07Z")

</div>

Ok I just edited your first post to see your code and I see some errors.

You are loading a .html file into a .php file. I don’t think that works.

And your SSI include is written wrong.

```php

<!--#include virtual="yourFile.txt"-->

```

I believe SSI has to be .txt files, but I have never experimented with .html extentions.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 1:59pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/6 "2002-12-19T13:59:58Z")

</div>

yea, for SSI you need a .txt file, and not php/html. and im 99% sure the file has to be .shtml - but im not 1% sure… :evil:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 2:49pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/7 "2002-12-19T14:49:59Z")

</div>

_sigh_ Somedays I forget how to spell my own name and I think this is one of them. I’ve tried your suggetions but it’s still not working. I have a test page up at [www.soacorp.com/date.html](http://www.soacorp.com/date.html) The date and time should show but it doesn’t and I’m completely frustrated. Could you please take a look?  
Sara  
P.S. I’d rather use PHP then HTML but… baby steps… =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 3:01pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/8 "2002-12-19T15:01:42Z")

</div>

```php
<!--#include virtual="date.txt"-->

```

you used that. if your using SSI (which i guess you want to do) this is what you need to use

```php
<!--#include file="date.txt"-->

```

FILE not VIRTUAL  
and that should do ya for. 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 3:01pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/9 "2002-12-19T15:01:53Z")

</div>

Hey Sara,

Well, Are you searching now for a script that output’s the time?

h88 8]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 3:40pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/10 "2002-12-19T15:40:01Z")

</div>

I’m trying to do 2 things. I really am trying to get the time to show on my pages but I’m mostly trying to figure out how to use Server Side Includes. I thought I’d start with something simple, like the time, but it’s not working out very well. _shrugs_ I might have to break down and buy a book.

redViper… I changed the “virtual” to “file” and nothing showed up. I also changed the “html” to “shtml” and still nothing showed up. I’m getting ready to put the blame on my ISP. =)

JustSara

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 3:52pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/11 "2002-12-19T15:52:51Z")

</div>

so its at file and .shtml?  
and its still not working?  
then your host doesnt allow it.

:elderly:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 7:35pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/12 "2002-12-19T19:35:10Z")

</div>

> \*Originally posted by redViper \*  
> \*\*yea, for SSI you need a .txt file, and not php/html. and im 99% sure the file has to be .shtml - but im not 1% sure… :evil: \*\*

It depends on your server. Certain servers (such as linux) require the file to be .shtml extentions, but others allow you to use .html.

Also, I believe some servers also make you use .shtm because it can only read 4 letter extentions. Maybe try that JustSara.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 15, 2003, 2:39pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/13 "2003-01-15T14:39:28Z")

</div>

Try putting \<?PHP\> Tags around your include and I think you’ll find it will work.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 15, 2003, 3:23pm UTC](https://forum.kirupa.com/t/php-ssi-includes/9793/14 "2003-01-15T15:23:35Z")

</div>

you can only include text file - put your html markup in the text file and that should work, check your permissions on your file too. 😉
