PHP/SSI Includes

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 include('date.html'); ?>

and I tried an SSI

<!--#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 if that helps at all.
Much thanks
JustSara

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

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…

<? 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 :-\

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.

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?

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.


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

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

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:

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 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… =)

<!--#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

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

FILE not VIRTUAL
and that should do ya for. :smiley:

Hey Sara,

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

h88 8]

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

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

:elderly:

*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.

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

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. :wink: