RE: [PHP] IP Address Converted to Computer Name

From: Date: Tue, 20 Nov 2001 01:08:38 +0000
Subject: RE: [PHP] IP Address Converted to Computer Name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75189@lists.php.net to get a copy of this message
Thanks for your response David. I am new to PHP. Are you saying that the code would look like this: <? gethostname for $IPADDR; if $HOSTNAME = $IPADDR print "$HOSTNAME" ?> Would I then put the $HOSTNAME into my mail() script. Sorry for the trouble. Ben -----Original Message----- From: David Robley [mailto:huntsman@www.nisu.flinders.edu.au] Sent: Monday, November 19, 2001 4:29 PM To: Ben Clumeck; php-general@lists.php.net Subject: Re: [PHP] IP Address Converted to Computer Name On Tue, 20 Nov 2001 04:08, Ben Clumeck wrote: > I am trying to convert an ip address to a computer name. Then I am > putting it into the mail() script. However, when I do this it come up > blank. I am putting $r_hostname in the mail() script. Can anyone tell > me why its not working? The script I am using is: > <? > $r_hostname = gethostbyaddr($REMOTE_ADDR); > if ($REMOTE_ADDR == "$r_hostname"); > echo "$r_hostname"; > ?> > > Thanks, > > Ben Remember that not all IP adrresses will resolve to a hostname. That said, there may be a flaw in your logic in the code snippet above :-) What you are saying is: gethostname for IPADDR; if HOSTNAME = IPADDR print HOSTNAME which will only work if the resolved hostname is the same as the IP address; I suspect that is not what you want? -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Bald: follicularly challenged. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#75189) next »