/    Sign up×
Community /Pin to ProfileBookmark

Server Side Includes problem

Server Side Includes problem.

I apoligise in advance if this is in the wrong section.

I have an Apache server set up at home on my Window’s based PC. I have successfully got a server side includes to work using…

<!–#include virtual=”tbd.php” –>

This piece of coding is in a file called index.inc.php that is stored in…

home/ccdata/data

This file is called by the index.php page foud in…

home/

tbd.php is also located in home/

I hope that all makes sense.

So anyways, on my Windows PC, I have this working.

I uploaded these files to two Linux based hosting accounts I have with different companies and have the same problem on both. I’ve carried out a test to see what the problem is.

I’ve tested two simple php files.

tbd2.php is included in untitled.php using…

<!–#include virtual=”tbd2.php” –>

This did not work (also tried file=).

However, if I change this code to…

<?php include(“tbd2.php”); ?>

..it works. It does not matter what level the files are at…by adjusting the path it works.

With regard to my three files above….tbd2.php is included in the index.inc.php which is called by index.php…

the include does not display when I open up index.php in a broswer.

All the other page elements are visible….but where the tbd.php is supposed to be, there’s nothing.

I’ve spent two days on this and can’t see what the problem is. Clearly “includes” work on the two linux hosting accounts…so the problem must be to do with the way the includes is called upon by the index.php page, via index.inc.php on a Linux server. Yes…no? ?

Here’s the site…

[url]http://wwww.raizwan.co.uk/ll[/url]

The content contained in tbd.php should appear under the three images (Barbara speers, la bass and kekoo).

Here’s the untitled.php page…

[url]http://www.raizwan.co.uk/ll/untitled.php[/url]

This has two includes…

<?php include(“images/tbd2.php”); ?> – works.

<!–#include file=”images/tbd2.php” –> – doesn’t work.

Sorry for the long post…but any ideas?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@criterion9Nov 26.2010 — The server may not have SSI enabled. It is better to use the include statement in php if you are already using php files anyway.
Copy linkTweet thisAlerts:
@riz-manauthorNov 26.2010 — It is enabled since the simple test I did worked.

File1.php includes File2.php, using the code...

<?php include("file2.php"); ?>

What does not work is when <?php include("file2.php"); ?> is placed in another file called data.php and file1.php is calling on it.

I hope that makes sense.

The site I'm making is e-commerce and the content of each page (e.g. index, about us, contact us) is called from another file (called data.php). As a result, the include code that appears on my main pages is actually stored in data.php.

I'm assuming this is the problem.

When you view the souce of the index.php (link in my original post) you will see the code...

<?php include("tbd.php"); ?>

The page works fine apart from that. It's as if this code has been completely ignored.
Copy linkTweet thisAlerts:
@riz-manauthorNov 26.2010 — Just realised in my many attempts at finding a solution...the page I currently have uploaded contains the code....

<?php include($DOCUMENT_ROOT . tbd.php"); ?>

That does not work either.
Copy linkTweet thisAlerts:
@riz-manauthorNov 26.2010 — Nevermind, I got it working.

I used echo to call the include from within the index.inc.php...and not from the file that contained the data (i.e. data.php). ?

It seems that while an Apache server on Windows (on my PC) didn't have a problem having three files involved in this process...Linux doesn't like it. ?
Copy linkTweet thisAlerts:
@criterion9Nov 26.2010 — Has the problem changed?

I thought the problem was that an SSI wasn't working while the PHP function was behaving as expected?

<?php include("images/tbd2.php"); ?> - works.

<!--#include file="images/tbd2.php" --> - doesn't work.
[/quote]


The new problem sounds like it might be a pathing problem. Linux is case-sensitive while Windows is not. That is one common problem.
Copy linkTweet thisAlerts:
@riz-manauthorNov 26.2010 — No the problem didn't change and I apologise if my explanation of it was poor (there were several points made in the first post).

Basically my site works like this...

index.php draws its content from a file called index.inc.php...which in turn draws part of its content from a file called data.php (I'm not even a novice user of PHP so don't ask my why it works this way).

the include code...

<?php include("images/tbd2.php"); ?>

...was in the data.php.

On Windows I had no problem. Index.php displayed as expected.

However on Linux the included data did not display. It did, however display if I put <?php include("images/tbd2.php"); ?> in index.inc.php.

I don't know if it's a path problem because includes do work on my Linux hosting....just not with the file setup I was using.
Copy linkTweet thisAlerts:
@criterion9Nov 26.2010 — What is the folder structure you are using? Which page is actually being requested by the browser?
Copy linkTweet thisAlerts:
@riz-manauthorNov 26.2010 — /index.php

/images/tbd2.php (include file)

/ccdata/data/index.inc.php

/ccdata/data/data.php

<?php include("images/tbd2.php"); ?> is in data.php.

index.php calls the code <?php include("images/tbd2.php"); ?> from data.php, via index.inc.php.

To get this working, I simple removed data.php from the process by putting <?php include("images/tbd2.php"); ?> in index.inc.php.
×

Success!

Help @riz-man spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...