Jump to content
xisto Community
Amezis

<? Include ?> Problems

Recommended Posts

Well, I'm new to PHP, and I get tons of problems when I use the include tags:Let's say my site is http://www.mysite.com/, and the menu is http://forums.xisto.com/no_longer_exists/. The site I want to include menu.htm in is not in the same folder as menu.htm, but in "folder2": http://forums.xisto.com/no_longer_exists/ images in menu.htm are located in it's own folder: http://www.mysite.com/ images. However, when I load index.php with <?php include '../menu.htm'; ?>, the images won't load. Then I try to check the image location and it says that the images that didn't load was located in http://www.mysite.com/ folder2/images/

 

Why do it change folder? And how can it be fixed?

Share this post


Link to post
Share on other sites

The image paths in menu.htm are just /images/image.jpg

 

As this is a relative path it will look for a folder called images inside whatever folder it is in. If you give FULL paths to all your images then it will work. E.g.:

 

http://forums.xisto.com/no_longer_exists/

 

is a full path.

165431[/snapback]

Umm, /images/image.jpg won't work when you're dealing with relative paths in php.

 

Try this code:

<?php include("/home/[cpanel login name]/public_html/menu.htm"); ?
That will be your include code for menu.htm. Replace [cpanel login name] with your cpanel login name.

 

If you need anymore help, PM me.

Share this post


Link to post
Share on other sites

Since you are including a file found in another folder, different where the index.php file is, you're gonna have to change the images path in menu.htm from whatever it is and add "../" to the begining. Since index.php is in folder "folder2", and in menu.htm says the images are in the images folder, and the menu.htm is being included in index.php, php thinks that you are trying to load images founded in "folder2/images/". I hope this make sense to you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.