PDA

View Full Version : "Includes" aren't working correctly.


ADeCilio
09-02-2010, 06:29 PM
To All,
I followed the instructions given to me about adding includes to my site. I put the menu I was working with that I wanted to make the include into a folder called "includes". But, the minute I go down another folder level and try to use the include, I get an error on the page.

Here is the sample

Works:
http://www.shbt.com/html/collection_test.html

Here is the error page:
http://www.shbt.com/html/adex/adex_test.html

The includes folder resides among the within the html folder. And as you can see, the error page has another folder level. Can someone please help me with this issue.

Thank You
Anthony

DWcourse
09-02-2010, 08:21 PM
can you show us the actual code you used to insert the include?

ADeCilio
09-03-2010, 01:16 PM
I hope this is what your talking about. This code is on this link that i posted here


Here is the error page:
http://www.shbt.com/html/adex/adex_test.html

<!--#include file="../includes/menu.php" -->

DWcourse
09-03-2010, 03:50 PM
The link is relative to the page it appears on. So for the boken page he link should be <!--#include file="../../includes/menu.php" -->

Corrosive
09-03-2010, 05:06 PM
Sorry ADeCilio but haven't we already covered this? http://www.dreamweaverclub.com/forum/showpost.php?p=182095&postcount=7

ADeCilio
09-03-2010, 05:51 PM
Sorry to have reposted. But Im getting stuck so I thought that if I posted in the php forum., someone would know. Sorry, my bad. Still having the problems with gooing down another sub directory. And adding the extre "../" doesnt help either.

Anthony

Corrosive
09-03-2010, 06:10 PM
No problem. We will work through stuff with you so you can just carry on the original thread :)

It seems very strange that adding the extended file path doesn't work. Must be missing something obvious...

Can you post your code for a page as by the time the page source is viewed the PHP has been parsed and the error pops up.

ADeCilio
09-03-2010, 06:19 PM
copy and paste the source code here?

DWcourse
09-03-2010, 08:32 PM
This should work anywhere on the site (including in a template) although it will just appear as a php icon until you load it to the server:

<?php include ($_SERVER['DOCUMENT_ROOT'].'/html/includes/menu.php');?>

ADeCilio
09-07-2010, 02:25 PM
Ugh.... I put in the code that you showed me and I am still getting the error message. Take a look.

http://www.shbt.com/html/adex/adex_test.html

I want to thank everyone for their help and standing by me in this dillema. Once I get this to work, I swear.....

Anthony

Corrosive
09-07-2010, 07:16 PM
Hi Anthony

I am at a total loss as to why it isn't working for you. You've copied JCs code and the paths are definitely correct? Could you post the php code again for the page that is working and the page that isn't.

ADeCilio
09-07-2010, 07:22 PM
Here is the post again. Below are the links that are both working and not working.

Here is the sample

Works:
http://www.shbt.com/html/collection_test.html

Here is the error page:
http://www.shbt.com/html/adex/adex_test.html

The includes folder resides among the within the html folder. And as you can see, the error page has another folder level. Can someone please help me with this issue.

Thank You
Anthony

Corrosive
09-07-2010, 07:39 PM
Hi Anthony

We have seen the pages where it is and isn't working but that's no use to us as I have explained before. The PHP is parsed by the server and html output before we get to see the page so we really need you to post the code you are using.

View source on the page and you'll see what I mean. The code is gone.

DWcourse
09-07-2010, 07:43 PM
Afraid we may be overlooking the obvious answer. Your page is a .html page. Either switch to .php or make sure your server is configured to process .html as .php.

I don't know where the error comes from but the php code is in the source and not being processed:

[an error occurred while processing this directive]
<?php include ($_SERVER['DOCUMENT_ROOT'].'/html/includes/menu.php');?>

Corrosive
09-07-2010, 07:53 PM
Don't think so. I gave this link in a previous thread covering that; http://www.desilva.biz/php/phpinhtml.html

Plus one of the includes is working and one isn't. It has to be in the syntax somewhere.

DWcourse
09-07-2010, 07:57 PM
I know but the php code is showing up in the source of the page. Wondering if he could somehow have limited the html as php to only one directory:confused:

Corrosive
09-07-2010, 08:09 PM
But it knows that it is trying to parse something. If it was acting as html it wouldn't would it? It's been a LONG day so may be way off the mark.

DWcourse
09-07-2010, 08:31 PM
In the page that works there is this bit of code above the include:

<style type="text/css">
<!--
.style24 {color: #F7F7F7}
-->
</style>

That's right where the problem occurs with the broken include. If it's on the broken page try removing it. Don't know why it might affect one page and not another but it's worth a try.

edbr
09-08-2010, 02:10 AM
copy the file into the same folder as the working one just to eliminate any folder problem. the include folder is one level up so hardcoded it would read
<?php include ('../html/includes/menu.php');?>
or use an absolute path

Corrosive
09-08-2010, 07:10 AM
I can't really fathom why people would split html (public facing) files into sub folders. There is a prize for anyone who can give me one good reason why they shouldn't just all be in the root?

DWcourse
09-08-2010, 07:17 AM
I do it for organizational purposes with large sites. It just makes it easier to find what I'm looking for. And also for SEO purposes to get a term in the url (of course I could just hyphenate it).

Anyway I use includes for menus and never have any problem getting them to work.

Corrosive
09-08-2010, 07:28 AM
But it is as easy to find a page called (for example) articles_dont_use_tables_for_layout.html in the public/root folder as it is to find it in articles/dont_use_tables_for_layout.html. It is all listed alphabetically so I don't see what the advantage is?? Also that is perfectly good (if not better) for SEO. Plus (if you use relative paths in your code) you end up with different routes to things like CSS, includes, javascript etc. and that can just get confusing as well.

With everything named sensibly (page type first and then the page name) it can all just go in the root.

Plus if I were contemplating a site that big I'd be looking at CMS with a decent taxonomy system :)

Sorry JC, no prize yet... not convinced 'organising' a site in this way doesn't cause more trouble than it is worth.

ADeCilio
09-08-2010, 07:07 PM
Hi Anthony

We have seen the pages where it is and isn't working but that's no use to us as I have explained before. The PHP is parsed by the server and html output before we get to see the page so we really need you to post the code you are using.

View source on the page and you'll see what I mean. The code is gone.


You want me to copy and paste ALL the code here?

gentleone
09-08-2010, 08:03 PM
You want me to copy and paste ALL the code here?

Yes, but wrap it in HTML tags or if it's a php page in PHP tags in the 'advanced editor'. In the toolbar the second row the last two icons.

ADeCilio
09-09-2010, 01:04 PM
OK., so I tried to post and it says it is too long in charcters. Any other suggestions?

ADeCilio
09-20-2010, 03:54 PM
OK., I tried using an absolute path on the php include and still no luck, someone please look. Im even willing to talk on the phone about this. Here is the link

http://www.shbt.com/html/adex/adex_test.html

Thank You for standing by me in this.

ADeCilio
09-20-2010, 04:47 PM
ALL Set. I finally figured out the problem. I want to thank you all for helping and putting up with me.

Corrosive
09-20-2010, 04:48 PM
ALL Set. I finally figured out the problem. I want to thank you all for helping and putting up with me.

And what was the problem/answer?

ADeCilio
09-20-2010, 06:54 PM
The Include had to be virtual... Looks like this

<!--#include virtual="includes/menu.php" -->

Thanks for all your help