Includes directive

I’ve been all over the map and now probably cannot find the forrest because of all these darn trees, but…
I created a test album using the extension .shtml

I put the following code in my pages:
’< !–#include file="<%=label+".txt"%>" – >’
(purposely garbled a little so it shows)
This seems fine IF I have that txt file loaded-I want that particular text file to appear on the page IMG_1234.shtml but if I don’t have that file, I get a “[an error occurred while processing this directive]” I thought nothing shows if not there.

Do I need to “test” for the file first. I really have been all over including:,PHP&Databases/_SSI:_Server-Side_Includes

I feel like I’m in the second semester of first grade here and everyone is doing post graduate work. Any help greatly appreciated.

(apparently one can’t edit one’s own message here after a time)

I’ve done more searching on includes and supposedly everything is to be lower case. So the line in my web page now reads (in part):
… “img_1234.txt” -->
which also incorporates the space after txt" but I still get the error message when no such file is there. How do I avoid getting that error? And if I need to construct an if/else, please be specific-I think I’ve used all my allotted neurons already on this. Again, TIA

The Apache HTTP Server documentation pretty much covers it.

You want to look into the changing the error message to be blank. By default the error message will indicate an error has occured.

:cool: Perl / MySQL / HTML+CSS

My understanding, SSI is for including something. Nothing is not something in this case, so if there’s nothing to include, that’s the definition of an error.

PHP may work better for you.

Thank you for your responses. I was coming to the conclusion that nothing is something, but kudos to the Apache link (best one yet and I must have looked at a dozen) and the idea of changing the error message (they even showed it fortunately) and that worked. I config’d the error to “” and used my original code. I am a happy puppy!

I made a web photo album and I wanted a way to simply update/add comments I might think of after the fact for individual photos. Yes, php would seem more suited, but as you might imagine, I was lost with “includes” so php is a little more down the road. Now to figure out how to format my included text… Thank you both again.

Gotcha. I, too, started with SSI before I learned any PHP. It’s robust yet simple.

One tip from my experience, is to name all your files with the .php extension. SSI should still work, but if you want to add PHP later it makes things easier.