Forum Moderators: coopster

Message Too Old, No Replies

PHP includes and tables

Loss of content on webpage because of different catalogs

         

DunDun

4:25 pm on Jan 24, 2003 (gmt 0)

10+ Year Member



I've managed my web-page in PHP using includes in a table cell. Because of my design I want the guestbook to be in the same table cell. But when I include the guestbook, which is located in another catalog, all content in the guestbook is missing. Do I have to move all the guestbook content to the root or is there anything else i can do?

jatar_k

6:09 pm on Jan 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Hey DunDun,

I don't totally understand what is happening, a couple of questions

which is located in another catalog

does this mean another site or just somewhere else on your site?

You don't have to move it to the root, you can include from anywhere.

Do you have any idea whether it is the include that is not working or the code being included that is messing things up?

When you view source on the page including the other content is there any of the guestbook content code there?

DunDun

12:13 am on Jan 25, 2003 (gmt 0)

10+ Year Member



Thanks for your answer jatar_k.

The guestbook files are located in a subdir from the root of my site. When I include the index.php from the guestbook directory in the index.php on the root, the messages written in the guestbook showes up in the table cell. But it won't load the rest of the files in the guestbook directory (images, css ++).

jatar_k

12:28 am on Jan 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



my guess is that all the paths are relative to its previous position.

when you include the file from
/dir/index.php into /index.php
the relative paths will, obviously, not be the same.

I would suggest that in the file you wish to include that all paths are "root relative". All links should start with / and carry on from there. This way, no matter where it lives on the site it knows where to find everything.

DunDun

12:35 am on Jan 25, 2003 (gmt 0)

10+ Year Member



Does that mean that i have to rewrite all the file locations in the .PHP-files? When I try to load the guestbook files from the root it still can't load anyt of the others. It's just the guestbook/index.php that loads properly.

jatar_k

12:39 am on Jan 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you are including the whole file it may have double html, head and body tags too.

The include should look like this

<? include "guestbook/index.php";?>

look at the url's to images and files from there. If they look something like "images/pic.gif" or "../images/pic.gif" then they won't work. Try one and see if it helps. If the images directory is in the root dir then they should look like this.

/images/pic.gif

This will work no matter where the file is moved to in the directory tree.

DunDun

12:44 am on Jan 25, 2003 (gmt 0)

10+ Year Member



I've started to rewrite the whole script, but it's difficult to change all the locations that should be generated by the changes done in the control panel/interface of the script.

jatar_k

12:45 am on Jan 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try one first and then see if that is the answer, then you don't go through the whole thing and find out you have to do it again. ;)

DunDun

12:51 am on Jan 25, 2003 (gmt 0)

10+ Year Member



A huge job, but it's necessary. Thanks for the help! :)