Hey guys i was coding an object orientated login (in php) and came across a problem i havnt seen before haha ok basically im having problems including files here is my folder structure:
_classes
images
includes
member
scripts
stylesheets
ok everything works perfect! except when the login page redirects the verified user to member i am getting include errors because my files are needed by the classes etc in the root.
is there away to combat this in php for example if such and such a page requests me (meaning the needed include) then my directory should be ../includes/db_settings.php
sorry if this makes no sense but hope someone can help!
php noob question includes etc
Moderator: General Moderators
-
TheMadHatter
- Forum Newbie
- Posts: 1
- Joined: Tue Apr 27, 2010 4:14 pm
Re: php noob question includes etc
Use absolute paths. $_SERVER["DOCUMENT_ROOT"] will get you to the web root - simply add a path from there.
Code: Select all
include $_SERVER["DOCUMENT_ROOT"] . "/includes/db_settings.php";- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php noob question includes etc
Use absolute paths. Have the base path in your configuration data and concat the file name you want to include to the base path.
(#10850)