top_left top_right
bottom_left
Next Event: Unknown | Forum Rules | QGL Website | Event Registration
openFolder AusForums.com
iconwatfolderLineopenFolder LANs
iconwatfolderLineopenFolder QGL
iconwatfolderLineopenFolder QGL Forum
Author
Topic: referencing file problem
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?!
system
--
épic™
Posts: 2093
Location: Brisbane, Queensland
use the actual path ?

\\home\www\etc\whatever
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
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
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
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/
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
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
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
system
--
Not a new post since your last visit.
New Post Since your last visit
Back To Forum
Advertise with Us | Privacy Policy | Contact Us
© Copyright 2001-2026 AusGamers Pty Ltd. ACN 093 772 242.
Hosted by Mammoth Networks - Australian VPS Hosting
Web development by Mammoth Media.