Forum Moderators: coopster

Message Too Old, No Replies

Include File Problems:

include file problems

         

petsitterbible

2:02 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



Hi,

I'm having a problem with my "include files" working correctly for page that have the pages hosted anywhere but my root folder:

example this works fine:

<snip>

but this doesn't:

<snip>

I tried having the address to include files be the full address: example: <snip>

But this has not worked either - can anyone help me with this? I assume it's a basic issue of where the files are stored but I can't figure this out - thank you for your time!

[edited by: dreamcatcher at 2:15 pm (utc) on Mar 1, 2010]
[edit reason] no urls please, see T.O.S [/edit]

Matthew1980

2:07 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there petsitterbible,

Welcome to the forum, for anyone to evaluate the situation you would need to post a portion of the code where the include(); sits, as there could be any number of things potentially causing the mismatch. Hopefully though, it's something that can be resolved easily.. ;-p

Cheers,

MRb

petsitterbible

2:27 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



Ahh, yes, sorry about that:

code where include files work:

view-source:

code where include files do not work:

view-source:

If anyone would prefer me to pase the code straight into the forum here please let me know, thank you.

[edited by: jatar_k at 2:53 pm (utc) on Mar 1, 2010]

jatar_k

2:54 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld petsitterbible,

better to paste the offending php code into the forum since we can only see the output, not the php. Try to reduce the code down to the lines that are not working properly, not just paste the whole page.

petsitterbible

3:20 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



Hi, sure thing!

Working page:

<ul id="nav">
<li><a href="http://example.com/index.shtml"><em>BUY THE BOOK</em><span>&nbsp;</span></a></li>
<li><a href="http://example.com/how_to.shtml"><em>LEARN MORE</em><span>&nbsp;</span></a></li>
<li><a href="http://example.com/forum/"><em>DISCUSS</em><span>&nbsp;</span></a></li>
<li class="active" ><a href="http://example.com/videos.shtml"><em>VIDEOS</em><span>&nbsp;</span></a></li>
<li><a href="http://example.com/forms.shtml"><em>FORMS</em><span>&nbsp;</span></a></li>
</ul>
</div>
</div>
<div id="footer">
<ul class="nav">
<li><a href="shopping_cart.shtml">buy the book</a></li>
<li><a href="how_to.shtml">learn more</a></li>
<li><a href="movies/movies.shtml">vidoes</a></li>
<li><a href="forum/">discuss</a></li>

</ul>
<ul>
<li><a href="sitemap.shtml">site map</a></li>
<li><a href="privacy_policy.shtml">privacy policy</a></li>
</ul>
</div>

non-working page (online):

<div class="holder">
<div class="right-panel">
[an error occurred while processing this directive]
[an error occurred while processing this directive]


</div>
<strong class="logo"><a href="index.shtml">Book Title</a></strong>
</div>
[an error occurred while processing this directive]
</div>

[an error occurred while processing this directive]
</div>

non-working page (not online):

<div class="right-panel">
<!--#include virtual="http://example.com/inc/top-nav.tpl" -->
<!--#include virtual="http://example.com/inc/search.tpl" -->


</div>
<strong class="logo"><a href="index.shtml">Book Title 2</a></strong>
</div>
<!--#include virtual="http://example.com/inc/movies.shtml" -->
</div>
<!--#include virtual="http://example.com/inc/footer.tpl" -->
</div>

Hope this helps? please let me know if I can provide anything else

[edited by: tedster at 12:59 am (utc) on Mar 2, 2010]
[edit reason] use example.com, please [/edit]

Matthew1980

3:28 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi petsitterbible,

I have a feeling as this code is from page source, not php/html code as:

[an error occurred while processing this directive]

is from the browser side ie, outputted content to browser. ;-)

Have you got the actual php file that you can post the erroneous code onto the forum at all? Then we can see where a potential error would be...

Either that or I have read the post totally wrong, lol!

Cheers,

MRb

petsitterbible

3:39 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



Hi, thanks for your help - hmm, sorry, when I saw the word server side maybe I got confused and thought this section was for my problem? I don't believe there is any .php file associated with this page - should I post elsewhere? thanks again

rocknbil

10:19 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm having a problem with my "include files" working correctly for page that have the pages hosted anywhere but my root folder:


You're correct, the General or New to Web. Dev. forums might be more appropriate, but it's OK, if the mods deem it so, they will move it. If the topic gets moved, a shadow copy will be left here.

PHP includes and SSI (server side includes) are not the same thing. Everyone in this forum will recommend you switch to PHP includes. <EG> However, in the context you're using it, I think PHP includes would be overkill, SSI's are "the right tool for the job."

Anyway on to your problem:

<!--#include virtual="http://example.com/inc/top-nav.tpl" -->
<!--#include virtual="http://example.com/inc/search.tpl" -->

These are server side includes, a technology used long before PHP to include a file (or output from a program) in an otherwise static page. But note that they are a file include, not an HTTP request - they are meant to include a file on your system. External links will never work.

You use the file directive if it's in the same directory, the virtual directive if it's in a different directory. So if you have

index.shtml
inc/top-nav.tpl
inc/search.tpl

And the includes are meant to be included in index.shtml, or even index.php, in which the output of your PHP has a server side include, this should work:

<!--#include virtual="/inc/top-nav.tpl" -->
<!--#include virtual="/inc/search.tpl" -->

And welcome aboard!

petsitterbible

1:07 am on Mar 2, 2010 (gmt 0)

10+ Year Member



thanks so much and to all the others who tried to help me too / your correction worked and I was missing a backslash, thanks again!

Matthew1980

8:07 am on Mar 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there petsitterbible,

Glad as its all sorted out, I have learnt something too, I had never heard of SSI until rocknbil gave that great explanation, my to-do list is getting ever longer ;-p

Cheers,
MRb

petsitterbible

3:02 pm on Mar 2, 2010 (gmt 0)

10+ Year Member



yes sir, it was a great explanation and has motivated me to learn more about php for my next website, thank you