Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1122 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

go back one step with folders in php

Thread title: go back one step with folders in php
Reply    
    Thread tools Search this thread Display Modes  
11-23-2009, 12:18 PM
#1
.Cyanide is offline .Cyanide
Status: Senior Member
Join date: Mar 2006
Location: Stockholm,Sweden
Expertise: Web Design, Coding
Software: Phoshop CS3
 
Posts: 757
iTrader: 4 / 100%
 

.Cyanide is an unknown quantity at this point

Send a message via MSN to .Cyanide

  Old  go back one step with folders in php

Hey,

So I have this script where I need to include() a file which is located in a folder previous to the one I'm including from. Now I've tried:

include('./functions.php');

but that didn't work.

This is the structure of my root folder

root

/mufnacka
- lots of files

/cms
- lots of files
- functions.php (file i want to include in...)

/startsida
- admin_start (...this document)



Thanks!

Reply With Quote
11-23-2009, 12:32 PM
#2
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

Your current method is looking to the root folder for functions.php not to the CMS folder. (... you need to add the CMS folder in your path)

Reply With Quote
11-23-2009, 01:18 PM
#3
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

If you're in admin_start.php the relative path would be ../cms/functions.php

Reply With Quote
11-23-2009, 01:26 PM
#4
.Cyanide is offline .Cyanide
Status: Senior Member
Join date: Mar 2006
Location: Stockholm,Sweden
Expertise: Web Design, Coding
Software: Phoshop CS3
 
Posts: 757
iTrader: 4 / 100%
 

.Cyanide is an unknown quantity at this point

Send a message via MSN to .Cyanide

  Old

Originally Posted by Salathe View Post
If you're in admin_start.php the relative path would be ../cms/functions.php
I'm sorry, but that didn't work =/ I don't know if you understood my folders-model, but functions.php is located in mufnacka/cms/ while admin_start.php is located in mufnacka/cms/startsida/

Thank you!

EDIT: I think i fixed it, i just put "include('../functions.php');"

Reply With Quote
11-23-2009, 04:17 PM
#5
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Ahh, the folders weren't indented (or otherwise labeled as being within one another) so I assumed a different structure than it actually was.

Glad to see you got it sorted anyway.

Reply With Quote
11-26-2009, 06:12 AM
#6
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

You other alternative is to use the full path of your file so you won't get lost with going back and foward.

Try looking at $_SERVER['DOCUMENT_ROOT']

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed