error while using server variables
Moderator: General Moderators
error while using server variables
hi all
i am new to this forum n also to php
my problem is that i am getting error when using $_SERVER['DOCUMENT_ROOT]
Notice: Undefined index: DOCUMENT_ROOT
because i cannot get any value from $_SERVER['DOCUMENT_ROOT]
is there any changes to be made in php.ini if yes then what they are?
so anyone help me
thanks n with regards
CN
i am new to this forum n also to php
my problem is that i am getting error when using $_SERVER['DOCUMENT_ROOT]
Notice: Undefined index: DOCUMENT_ROOT
because i cannot get any value from $_SERVER['DOCUMENT_ROOT]
is there any changes to be made in php.ini if yes then what they are?
so anyone help me
thanks n with regards
CN
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Have a read through this thread to see if there is anything that can help.
Also, try searching these boards for the terms 'undefined index DOCUMENT_ROOT' using the match all terms selection. There are a lot of posts about this.
Also, try searching these boards for the terms 'undefined index DOCUMENT_ROOT' using the match all terms selection. There are a lot of posts about this.
- ronverdonk
- Forum Commoner
- Posts: 34
- Joined: Sat Jun 10, 2006 7:06 am
- Location: Netherlands
Bypass
Found the following entry in the "Predefined variables" chapter at php.net. I tested it and it works.
You could use this instead of the golbal DOCUMENT_ROOT.
You could use this instead of the golbal DOCUMENT_ROOT.
I was unable to convince my hosting company to change their installation of PHP and therefore had to find my own way to computer $_SERVER["DOCUMENT_ROOT"]. I eventually settled on the following, which is a combination of earlier notes (with some typos corrected):
Code: Select all
<?php if ( ! isset($_SERVER['DOCUMENT_ROOT'] ) ) $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr( $_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']) ) ); ?>
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA