Jump to content

[SOLVED] Problem with include command .. plz help


abdfahim

Recommended Posts

I new in php programming. I want to include a php file (top.php) into another (body.php). The file top.php is one level up. so the code looks  like ..
.....
//Code for body.php
include "../top.php";
......
Now the problem arises is, when I open body.php in a browser, it can't find the images attached in top.php. What can I do? Plz help me
Link to comment
Share on other sites

location of top.php = root/
location of body.php = root/nextfolder/

Then your include is right:
include '../top.php';

So i'd look at your top.php code, and find out where it's pointing to the images!
If you direct your browser to top.php, does it display all images correctly? If so, then that maybe your problem! It is the image path relative to the body.php path, and NOT the top.php path ;)
Link to comment
Share on other sites

ok ... i include my my top.php file and body.php file with this ... images of top.php file works good when i include top.php in files of same folder. But when i include it from different folder, the browser look for images in the folder where body.php resides, even if I use full url .. like

//code of body.php (which is in http://localhost/web/forum)
include "http://localhost/web/top.php";
....

[attachment deleted by admin]
Link to comment
Share on other sites

Thanx all... it works when I make all links absolute in top.php. But i wonder if it is possible to do same work with relative links in top.php? I guess not :(. And will it take longer time to load the images when I use absolute link then relative link?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.