|
Page 1 of 1 |
sTo0z
[Moderator] Babysitter
Posts: 7449
Location: USA
|
Posted: Wed, 27th Apr 2005 20:54 Post subject: PHP - Ok I'm stumped! |
|
 |
I have a file in this location:
/acs/utilities/Authorization.php
Inside this file I have this line:
require_once("../db/db_connection.php");
This is the db_connection.php location:
/acs/db/db_connection.php
Yet, when I run the file, I get a warning of no such file exists.
Just can't figure it out, any help would be appreciated.
|
|
Back to top |
|
 |
|
Posted: Wed, 27th Apr 2005 21:23 Post subject: |
|
 |
("../db/db_connection.php") you tried changing this to ("acs/db/db_connection.php") ?
meh i dont know PHP prolly donnt look like a tit as usual 
|
|
Back to top |
|
 |
Rinze
Site Admin
Posts: 2343
|
Posted: Thu, 28th Apr 2005 10:34 Post subject: |
|
 |
Php includes files from the path the file you open in the webbrowser.
So if you have
/index.php which does include('inc/asd.php');
/inc/asd.php which does include('inc/qwe.php');
/inc/qwe.php
You can open index.php from webhost and it will include asd.php which will include qwe.php, but you can't open /inc/asd.php from the browser, because that would try to include /inc/inc/qwe.php, which doesn't exist.
Solutions are to either always use fixed paths (but then you'd have problems changing webhosts/selling your scripts) or make sure you know which files will be opened from the webbrowser, and put them in the right directories, or use ini_set function to dynamically add include paths to your script.
|
|
Back to top |
|
 |
|
Posted: Sun, 15th May 2005 16:19 Post subject: |
|
 |
Are you including Authorization.php into another file in a different DIR? COs, you need to put the URL/DIR in terms of the file you are running and not in terms of the included file.
HTH and maybe makes sense?
|
|
Back to top |
|
 |
|
Posted: Sun, 27th Nov 2005 15:11 Post subject: |
|
 |
put the paths in a file like globals.php like this:
Code: |
<?php
$root = "<path to your htdocs directory>/";
$subdir1 = $root."subdir1/";
$subdir2 = $root."subdir2/";
$include = $root."inc/";
$database = $root."db/";
?>
|
Then include that globals.php file in your index.php file (if that's what you use). Now, when you want to include the db files, you could do:
Code: |
<?php
require_once($database."db_connection.php");
?>
|
Hope it helps
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |
|
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 2.0.8 © 2001, 2002 phpBB Group
|
|
 |
|