Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> <? Include ?> Problems
Amezis
post 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?
Go to the top of the page
 
+Quote Post
rvalkass
post Jul 25 2005, 08:37 AM
Post #2


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,254
Joined: 28-May 05
From: Devon, England
Member No.: 7,593
Spam Patrol
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.
Go to the top of the page
 
+Quote Post
Amezis
post 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...
Go to the top of the page
 
+Quote Post
snlildude87
post 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

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.
*

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

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.
Go to the top of the page
 
+Quote Post
truefusion
post Jul 25 2005, 07:37 PM
Post #5


Ephesians 6:10-17
Group Icon

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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problems With Apostrophes [ ' ] In Php(4)
  2. Php And Gd Tutorial(6)
  3. Postnuke Install Problems On Subdomains(1)
  4. Browser Problems, Maybe?(6)
  5. Problems With Php Form?(7)
  6. Include Funtion Php Problems(11)
  7. Major Problems With Php Script(8)
  8. Phpnuke Newsletter Sending Problems(0)
  9. Odbc Form Problems(0)
  10. Mysql Authentication Problems(11)
  11. Preg_replace Problems(7)
  12. Problems With Php(5)
  13. Problems With Data Formatting(2)
  14. Php Problems(3)
  15. Lots Of Problems.. Emergency(2)


 



- Lo-Fi Version Time is now: 1st December 2008 - 04:35 PM