Re: include, relative path



^AndreA^ wrote:
Hi everybody,

I'm having a stupid problem with the include command.
I looked around and I found some solutions but, I don't know why, they
don't work at all.

Briefly, this is the structure of my website:

mysite/libraries/db_details.php
mysite/registration/check.php

I need to connect to the database from the script "check.php", and the
details of the database are in "db_details.php", of course... ;-)

so, I have to include "db_details.php" from "check.php" script...

I'm under linux and I've tried so many different solutions without
success, maybe because of the PHP version (5.2.3)... and some
solutions I found were a bit old (2002, 2003) and so I thougth they
could not to work any more.

Here some of them,

ini_set("include_path",".:/libraries");

set_include_path('mysite/libraries/');

include('/..//libraries/db_details.php');

include("../registration/db_details.php");

include "db_details.php";

I'm fed up with that...

any help would very appreciated!!!

Thanks in advance

PS: I don't want to change php.ini settings because I couldn't do it
on my hosting server...


Use $_SERVER['DOCUMENT_ROOT'] to get to the root directory of your website, then reference from there, i.e.

include ($_SERVER['DOCUMENT_ROOT'] . '/libraries/db_details.php');

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: e-mail address mining tool?
    ... > Well, to be exact, almost no servers support this command nowadays. ... > Audit your website security with Acunetix Web Vulnerability Scanner: ... Cross site scripting and other web attacks before hackers do! ...
    (Pen-Test)
  • Re: zmodem protocol?
    ... > Has anybody heard anything about possible security flaws in "lrzsz"? ... And the website: http://www.ohse.de/uwe/software/lrzsz.html ... flow - not a problem with shell accounts using them on the command line. ...
    (FreeBSD-Security)
  • Re: getting absolute directory path?
    ... but not in the .php files, that may be a bit more of a challenge. ... that a website is not the right solution ... What was the wildcarding problem you had?The size of the command ...
    (comp.lang.php)
  • Re: getting absolute directory path?
    ... expands out past the cap, you'll get an "Arguement list too long" error ... this is starting to make sense as a difficulty in management. ... to the functions of the website, ... an instance where a file management task I'm doing on the command line ...
    (comp.lang.php)
  • Invisible Word
    ... If I attempt to do some automation from a web site (I do all of the ... will generate but will not look proper. ... a web context (from a little command line application wrapper) and the ... False' then the document generated by the website and the command line ...
    (microsoft.public.office.developer.automation)