How to get PHP to use relative filenames...

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Fri Feb 09, 2007 4:10 pm    Post subject: How to get PHP to use relative filenames... Reply with quote

I've been learning PHP since I got my Abyss Server ware, but now I am having trouble with relative links.

Problem is I have a lot of counters and other changing dynamic data on my website and I would like to put all the counters their own folder.

so root folder is /webserver/

counter.php is sitting in /webserver/2005/folder/counter.php

and counter.txt is in /webserver/counters/

How do I get php to read and write to the counters folder from the /webserver/2005/folder/?

PHP can't find that folder ... it keeps looking in the current folder its sitting in!
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Fri Feb 09, 2007 5:49 pm    Post subject: Reply with quote

Try using ../../counters/counter.txt
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Feb 09, 2007 10:51 pm    Post subject: Re: How to get PHP to use relative filenames... Reply with quote

Gannyaa,

Are you using Windows? Is /webserver/2005/folder/counter.php the real path in your hard drive of that file?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sat Feb 10, 2007 5:15 pm    Post subject: Reply with quote

Relative paths to counter.txt (works for filesystem calls and URLs when URL is available to server)

It's in current directory --> ./counter.txt
It's up one directory --> ../counter.txt
It's up two directories --> ../../counter.txt
It's in a subdirectory called today --> ./today/counter.txt

For filesystem calls, you might also consider hard-coded paths: (think a relative path that starts with the drive root)

/abyss/htdocs/today/counter.txt
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Tue Feb 13, 2007 4:44 am    Post subject: Thanks for all the replies ... Reply with quote

Thanks for your answers.

I think I'll try both the hard coding method and
http://domain.com/counters

the ../.. / etc or you know what I mean.
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Tue Feb 13, 2007 10:46 pm    Post subject: I had to re ply again! Reply with quote

Thanks cmxflash. I used that precisely ../../

I am using windows...
and I find php not as friendly as javascript or html or css

My actual web folder dir setup is kinda like...

my web
|_beach
|_gannyaa
|_wynston

each folder is set up sorta like so

/wynston/2005/
/wynston/2006/
/wynston/2007/
/wynston/2007/sir_kelsea/userdata/
/wynston/gbook/
/wynston/gbook/emotions/
/wynston/gbook/img/
/wynston/images/
/wynston/images/butterflys/
/wynston/scripts/

I'm not relocating the userdata into a separate folder but keeping the comment script (gbook) accessible by all php pages.

You're reply's have been most useful. I am still playing around with the captcha script ... but first I need my ArgoSoft to work with PHP.
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group