I'm tearing my hair out over this one, I'm hoping maybe someone here has some idea what's going on. I'm working on a script, and one of the things it needs to do is the first time it runs, it gets the hostname of the server it's on. Simple right? Well I was using: $hostname = gethostbyaddr($_SERVER(['SERVER_ADDR']); Code (markup): And it worked perfectly. I would get hostnames in the format of: name.server.tld After several hours of working perfectly however, it stopped! Now, it returns the hostname of the VISITOR! It is doing exactly what I would expect of: gethostbyaddr($_SERVER['REMOTE_ADDR']); Code (markup): except that, obviously, I'm not using that command! What the heck is going on here? I've changed nothing about my server settings, I've just been sitting here scripting all afternoon... this has happened totally out of the blue and I can't seem to fix it. Oh also, on occasion rather than return the visitor's host name, it returns the visitor's IP address, and also sometimes it will return the server's IP address, but NEVER the server's host name. Thanks for any insights... Jonathan
What output you get when you just echo $_SERVER['SERVER_ADDR'] and $_SERVER['REMOTE_ADDR']? Do these variables contain the expected content? Are you sure none of them gets overwritten accidentally somewhere in your script?
I'm actually testing with a whole separate script right now that is nothing BUT echoes of those variables... all I get is the IP address of my server, never the host name any more. I can't explain it... Jonathan
Well I came up with a better solution anyway, by parsing phpinfo(); on the server running the script. It works like a charm regardless of what's going on with the gethostbyaddr() function. Go figure... but all I care about is I colved the problem so I think we can call this thread closed... Jonathan