473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

not getting the ServerName in the $_SERVER[SERVER_NAME]

Hi, i have a php server on iis6 win2003. When i write in index.php <? phpinfo(); ?> it brings me the information of php server _SERVER["SERVER_NAME"] the name of localhost, but when i write the variable $_SERVER['SERVER_NAME'] i get an error PHP Notice: Undefined index: SERVER_NAME. Any ideas please? Is something to do with the php.ini or with the environment variables like DOCUMENT_ROOT?
Thank you.
Apr 14 '09 #1
2 14371
hoopy
88
Try:

Expand|Select|Wrap|Line Numbers
  1. echo ("<pre>");
  2. print_r($_SERVER);
  3. echo ("SERVER = " . $_SERVER['SERVER_NAME']);
  4. echo ("</pre>");
And see if it displays in that array. Im sure I read somewhere once that IIS can act differently due to an old spoofing vuln with the $_SERVER['SERVER_NAME'] variable so your problems could be related to that. .

As an alternative, see if you can use $_SERVER['HTTP_HOST']

Cheers.
Apr 14 '09 #2
pbmods
5,821 Expert 4TB
Heya, klehonia.

$_SERVER['SERVER_NAME'] is populated by Zend Platform. A stock PHP installation generally won't have this variable accessible.

Try $_SERVER['HTTP_HOST'] instead. You might have to explode('.') it if you only want a specific part of it.
Apr 15 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Leester | last post by:
Hi, Can anyone tell me if it is possible to generate the actual URL of the current PHP script (with all POST data included)? I have a third-party application that I'd like to use to see HTTP...
10
by: Spidah | last post by:
How do I get the contents of the browser address bar with PHP - assuming it is possible? In javascript it is done with: unescape(window.location.pathname), but is there a php equivalent? ...
3
by: junk | last post by:
Hi can anyone tell me why this doesn't work: <link rel="stylsheet" href="http://<?php echo $_SERVER; ?>/includes/test3.css" type="text/css" /> there is no wrap in the actual file. when I...
1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
10
by: Jim Carlock | last post by:
Looking for a way to extract the path from the pfqpn (partially full qualified path name). $sThisServer = $_SERVER; // returns either aquaticcreationsnc.com or www.aquaticcreationsnc.com ...
4
by: news | last post by:
I'm trying to mask a URL and found a great way to point one domain to another while keeping the original domain name in the browser address bar: <VirtualHost *:80> DocumentRoot...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
3
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 with Apache 2. How would I get the value of the "ServerName" attribute of the "<VirtualHostdirective in the Apache configuration (httpd.conf) file? I noticed that...
2
by: jodleren | last post by:
Hi For debugging, I created this: $stuff="Client information:\r\n". "Server name:\t".$_SERVER."\r\n". "Server addr:\t".$_SERVER."\r\n". "Server soft:\t".$_SERVER."\r\n". "Server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.