I have 2 server that run the same code. The code uses 2 deferent databases depending on which server the code is hosted (i.e. test and production). I used the $_SERVER['HTTP_HOST'] to find the server in question but my echo kept returning blank. I checked the register_globals and it is turned on
any ideas
thanks
--quan
$_SERVER['HTTP_HOST'] returning blanks
Moderator: General Moderators
-
PingLeeQuan
- Forum Commoner
- Posts: 58
- Joined: Tue Sep 03, 2002 8:08 am
-
PingLeeQuan
- Forum Commoner
- Posts: 58
- Joined: Tue Sep 03, 2002 8:08 am
OK... I am confused.. I thought the manual said the $HTTP_SERVER_VARS is deprecated and that we should be using the $_SERVER.
I ran phpinfo(); and i got the right stuff in the server name parameter
I also ran $HTTP_SERVER_VARS['SERVER_NAME'] I also got the right result.
I guess I was going by what the manual was saying
Thanks guys...
this is what the manual said
PHP Superglobals
$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the
script. The keys of this array are the names of the global variables. $GLOBALS has existed since PHP
3.
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the
current script. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but
deprecated).
I ran phpinfo(); and i got the right stuff in the server name parameter
I also ran $HTTP_SERVER_VARS['SERVER_NAME'] I also got the right result.
I guess I was going by what the manual was saying
Thanks guys...
this is what the manual said
PHP Superglobals
$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the
script. The keys of this array are the names of the global variables. $GLOBALS has existed since PHP
3.
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the
current script. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but
deprecated).
What version of PHP are you running? The "_SERVER" superglobal is only available for PHP 4.1.0 and later.
Also, you mentioned that "SERVER_NAME" on your phpinfo() page was correct. What about "HTTP_HOST" on the phpinfo() page? Are both present and equal?
I agree with you - I wouldn't want to use deprecated globals if I could help it.
Also, you mentioned that "SERVER_NAME" on your phpinfo() page was correct. What about "HTTP_HOST" on the phpinfo() page? Are both present and equal?
I agree with you - I wouldn't want to use deprecated globals if I could help it.
-
PingLeeQuan
- Forum Commoner
- Posts: 58
- Joined: Tue Sep 03, 2002 8:08 am