noob question about document_root

noob question about document_root

am 10.10.2007 13:27:19 von Francesco

Hy guys,
I'm new to php and I'm wondering why i get the notice
Undefined index: DOCUMENT_ROOT

if I write
define('ROOT_PATH',$_SERVER['DOCUMENT_ROOT'] .'/mypath')

But if I see the phpinfo() output the DOCUMENT_ROOT is properly set.

Thanks for any advice
Francesco

Re: noob question about document_root

am 10.10.2007 14:04:47 von BoneIdol

On 10 Oct, 12:27, Francesco wrote:
> Hy guys,
> I'm new to php and I'm wondering why i get the notice
> Undefined index: DOCUMENT_ROOT
>
> if I write
> define('ROOT_PATH',$_SERVER['DOCUMENT_ROOT'] .'/mypath')
>
> But if I see the phpinfo() output the DOCUMENT_ROOT is properly set.
>
> Thanks for any advice
> Francesco

My advice would be to do a print_r on $_SERVER. See what it comes up
with.
You may find that the superglobal is empty or unset if you are using
a very old version of PHP.

If this is the case, try using $HTTP_SERVER_VARS instead.

Re: noob question about document_root

am 10.10.2007 16:30:00 von Francesco

BoneIdol wrote:

> My advice would be to do a print_r on $_SERVER. See what it comes up
> with.
Hmmm you are right...
there is no DOCUMENT_ROOT defined in $_server array...

>
> If this is the case, try using $HTTP_SERVER_VARS instead.
>
....but it's the same for this one.

> You may find that the superglobal is empty or unset if you are using
> a very old version of PHP.

I'm using php 5.2.0.

As I said before, I actually can find the DOCUMENT_ROOT properly set in
phpinfo() output

* "Apache Environment" section, as
DOCUMENT_ROOT | c:/.../properPath

* and "PHP variables" section, as
_SERVER["DOCUMENT_ROOT"] | c:/.../properPath

Any ideas??

Thanks
Francesco

Re: noob question about document_root

am 10.10.2007 17:52:58 von klenwell

On Oct 10, 7:30 am, Francesco wrote:
> BoneIdol wrote:
> > My advice would be to do a print_r on $_SERVER. See what it comes up
> > with.
>
> Hmmm you are right...
> there is no DOCUMENT_ROOT defined in $_server array...
>
>
>
> > If this is the case, try using $HTTP_SERVER_VARS instead.
>
> ...but it's the same for this one.
>
> > You may find that the superglobal is empty or unset if you are using
> > a very old version of PHP.
>
> I'm using php 5.2.0.
>
> As I said before, I actually can find the DOCUMENT_ROOT properly set in
> phpinfo() output
>
> * "Apache Environment" section, as
> DOCUMENT_ROOT | c:/.../properPath
>
> * and "PHP variables" section, as
> _SERVER["DOCUMENT_ROOT"] | c:/.../properPath
>
> Any ideas??
>
> Thanks
> Francesco

Are you running your script for the command line? From
http://us.php.net/reserved.variables:

"You may or may not find any of the following elements in $_SERVER.
Note that few, if any, of these will be available (or indeed have any
meaning) if running PHP on the command line."

Re: noob question about document_root

am 11.10.2007 15:57:56 von Francesco

klenwell wrote:

> Are you running your script for the command line? From
> http://us.php.net/reserved.variables:
>
> "You may or may not find any of the following elements in $_SERVER.
> Note that few, if any, of these will be available (or indeed have any
> meaning) if running PHP on the command line."
>

I use easyphp 2.0 beta and the zend ide. I don't know if one of these
can cause the problem...

Re: noob question about document_root

am 11.10.2007 16:10:03 von Jerry Stuckle

Francesco wrote:
> klenwell wrote:
>
>> Are you running your script for the command line? From
>> http://us.php.net/reserved.variables:
>>
>> "You may or may not find any of the following elements in $_SERVER.
>> Note that few, if any, of these will be available (or indeed have any
>> meaning) if running PHP on the command line."
>>
>
> I use easyphp 2.0 beta and the zend ide. I don't know if one of these
> can cause the problem...

Are you trying to execute it in the ide? These are only available when
your php is running under a web server (i.e. you call up a web page).

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

Re: noob question about document_root

am 11.10.2007 17:42:28 von Francesco

Jerry Stuckle wrote:

> Are you trying to execute it in the ide? These are only available when
> your php is running under a web server (i.e. you call up a web page).

You are right, I'm able to reach it in the browser.

I guess that working with the debugger is similar, from this side, to
running my scripts from the command line. Am I right?

But is there a way to solve it if I want to debug my scripts in the ide?

How can include my files if I'm not able to reach document_root?

Re: noob question about document_root

am 11.10.2007 23:16:50 von Jerry Stuckle

Francesco wrote:
> Jerry Stuckle wrote:
>
>> Are you trying to execute it in the ide? These are only available
>> when your php is running under a web server (i.e. you call up a web
>> page).
>
> You are right, I'm able to reach it in the browser.
>
> I guess that working with the debugger is similar, from this side, to
> running my scripts from the command line. Am I right?
>
> But is there a way to solve it if I want to debug my scripts in the ide?
>
> How can include my files if I'm not able to reach document_root?

I tried the Zend IDE a while back, and decided it was a great IDE, but
not worth what they want for it. So when the trial was over I removed
it from my disk.

IIRC, there was a way to debug using the browser and web server, but I
don't remember what it was. You need to go back through the
documentation and find out how to do it.

Sorry.


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

Re: noob question about document_root

am 12.10.2007 01:01:29 von Bucky Kaufman

> Francesco wrote:

>> I guess that working with the debugger is similar, from this side, to
>> running my scripts from the command line. Am I right?
>>
>> But is there a way to solve it if I want to debug my scripts in the ide?
>>
>> How can include my files if I'm not able to reach document_root?

If you can FTP to the location, add that to the FTP servers settings.
Then, add those files to your project as you see fit.
Later, if you want to push the files out to a production server, it'll grab
'em from wherever they came from.