|
|
|
|
![]() ![]() |
Jul 25 2005, 08:21 AM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
Well, I'm new to PHP, and I get tons of problems when I use the include tags:
Let's say my site is www.mysite.com, and the menu is www.mysite.com/menu.htm. The site I want to include menu.htm in is not in the same folder as menu.htm, but in "folder2": www.mysite.com/folder2/index.php The images in menu.htm are located in it's own folder: 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 www.mysite.com/folder2/images Why do it change folder? And how can it be fixed? |
|
|
|
Jul 25 2005, 08:37 AM
Post
#2
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,254 Joined: 28-May 05 From: Devon, England Member No.: 7,593 ![]() myCENT:95.71 |
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://www.mysite.com/images/image.jpg is a full path. |
|
|
|
Jul 25 2005, 08:56 AM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
If there's not any other ways, I'll do that...
|
|
|
|
Jul 25 2005, 03:50 PM
Post
#4
|
|
|
Moderator ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,325 Joined: 8-March 05 From: Mawson, Antarctica Member No.: 4,254 |
QUOTE(rvalkass @ Jul 25 2005, 05:37 AM) The image paths in menu.htm are just /images/image.jpg Umm, /images/image.jpg won't work when you're dealing with relative paths in php.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://www.mysite.com/images/image.jpg is a full path. Try this code: 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. |
|
|
|
Jul 25 2005, 07:37 PM
Post
#5
|
|
|
Ephesians 6:10-17 ![]() Group: [MODERATOR] Posts: 1,994 Joined: 22-June 05 From: somewhere... Where am i? Member No.: 8,528 myCENT:72.96 |
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.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 1st December 2008 - 04:35 PM |