|
![]() |
|
| Author |
|
|||||||
|
diese1
Posts: 157
Location: Brisbane, Queensland
|
I'm trying to reference a file on my website without putting in the absolute path in. Because PHP doesn't seem to allow it.
So i've got this code: executing from the directory/file www.xxxxx.com/news/news/events.php but the forum directory is sitting www.xxxxx.com/forum/ anybody know the syntax to tell it to go back further up the file navigation/path?! |
|||||||
| #0 03:34pm 25/01/09 |
|
|||||||
|
system
|
--
|
|||||||
| #0 |
|
|||||||
|
épic™
Posts: 2093
Location: Brisbane, Queensland
|
use the actual path ?
\\home\www\etc\whatever |
|||||||
| #1 03:58pm 25/01/09 |
|
|||||||
|
whoop
Posts: 13441
Location: Brisbane, Queensland
|
../../forum/ ?
edit: Are you trying to reference it from the server or client side? last edited by whoop at 16:06:20 25/Jan/09 |
|||||||
| #2 04:06pm 25/01/09 |
|
|||||||
|
tequila
Posts: 655
Location: Sydney, New South Wales
|
create test.php and chuck this in it
phpinfo() ?> that'll give you all the info you need to figure it out |
|||||||
| #3 04:53pm 25/01/09 |
|
|||||||
|
nF
Forum Hero
Posts: 15335
Location: Wynnum, Queensland
|
it'll probably be /htdocs/news/news/events.php unless you're using vhosts (pretty sure php normally runs chroot)
is the double "news" bit intentional, or is that your error? last edited by nF at 17:38:45 25/Jan/09 |
|||||||
| #4 05:38pm 25/01/09 |
|
|||||||
|
diese1
Posts: 158
Location: Brisbane, Queensland
|
argh nuts my php code didn't show up in the post.
So i got this code ph includ3('./forum/topic_top.php'); ph includ3('./forum/topic_bottom.php'); and its in the file www.xxxxx.com/news/news/events.php but its trying to reference the topic_top.php and topic_bottom.php sitting in the directory www.xxxxx.com/forum/ |
|||||||
| #5 10:36pm 25/01/09 |
|
|||||||
|
tequila
Posts: 665
Location: Sydney, New South Wales
|
so do what I said..
put this in a file and run it on your webserver; print $_SERVER[DOCUMENT_ROOT]; it will return something like /home/username/www/website from that, you can assume that your website is in the directory '/home/username/www/website' etc then you can do this; include('/home/username/www/website/news/forum.php'); or whatever script you want its no different to if the file was in c:\news\forum\forum.php etc, it's just / instead of \ and theres no drive letter hint: the answer is using include('./news/news/topic_top.php'); last edited by tequila at 23:08:28 25/Jan/09 last edited by tequila at 23:37:08 25/Jan/09 |
|||||||
| #6 11:37pm 25/01/09 |
|
|||||||
|
whoop
Posts: 13444
Location: Brisbane, Queensland
|
include('../../forum/topic_top.php'); work?
Be aware that if there's anything in the forums php that has relative paths they'll also be broken, you'll need to either re-write the paths as absolute paths or write your own code to do what you want instead of incorporating the forums code... I think. last edited by whoop at 23:27:00 25/Jan/09 |
|||||||
| #7 11:27pm 25/01/09 |
|
|||||||
|
nF
Forum Hero
Posts: 15341
Location: Wynnum, Queensland
|
ph includ3('./forum/topic_top.php');
the ./ means current directory (ie, the one the current script is running from) so it'll try open www.xxxxx.com/news/news/forum/topic_top.php change the line to includ3('/htdocs/forum/topic_top.php') and if that doesn't work change it to includ3('/forum/topic_top.php') last edited by nF at 23:32:16 25/Jan/09 |
|||||||
| #8 11:32pm 25/01/09 |
|
|||||||
|
system
|
--
|
|||||||
| #8 |
|
|||||||
|
| ||||||||