php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12678 gethostbyname returns hostname instead of adresss
Submitted: 2001-08-09 15:57 UTC Modified: 2002-06-18 18:42 UTC
From: bobsledbob at yahoo dot com Assigned:
Status: Not a bug Package: Network related
PHP Version: 4.0.6 OS: Linux 2.2.16-22
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bobsledbob at yahoo dot com
New email:
PHP Version: OS:

 

 [2001-08-09 15:57 UTC] bobsledbob at yahoo dot com
I'm having a problem where gethostbyname is returning the hostname not the IP address.  Resolving hosts works fine on the command line with nslookup, host, etc.

This is the exact problem as bug #8856.  Andy said it should be resolved in 4.06, but I'm having problems.

Thanks.

Adam

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-09 16:02 UTC] alindeman@php.net
Can you access the internet from a browser?

gethostbyname() returns the hostname when it can't find the 
IP (invalid address.)

Make sure your nameserver's are setup correctly.
 [2001-08-09 16:13 UTC] bobsledbob at yahoo dot com
> Can you access the internet from a browser?

Yes, I can resolve any hostname using nslookup, host, etc.  This machine accesses the internet just fine.

ie.  from the command line:

[hydro@mail htdocs]$ host calc.intershipper.net
calc.intershipper.net is a nickname for www.intershipper.net
www.intershipper.net has address 216.58.153.11
[hydro@mail htdocs]$ 

but from PHP
<?php
echo gethostbyname ("calc.intershipper.net");
?>

calc.intershipper.net



> Make sure your nameserver's are setup correctly.

To the best of my knowledge, they are.


 [2001-08-09 21:51 UTC] sniper@php.net
Could you please try gethostbynamel() with the same 
hostname? 

(these both work for me just fine..)

--Jani

 [2001-08-10 13:06 UTC] bobsledbob at yahoo dot com
<?php
  $domain = "www.yahoo.com";
  echo gethostbyname($domain) . "<br>\n";
  print_r (gethostbynamel($domain));
?> 

www.yahoo.com
Array ()


As I've thought about this some, I believe I started having problems with this only after upgrading to 4.06.  It may have worked with 4.05 and I know it was working for me with 4.04plx   Maybe this has something to do with my Linux Disto?  I'm using RedHat 7.0

Thanks for your thoughts.  For now, I'm just hard coding the ip address I need, so it's not like this is bogging me down.

Adam

 [2001-09-25 16:47 UTC] jimw@php.net
duplicate of 13243. (yes, that's a later bug. but it documents the problem more concisely.)
 [2001-09-26 11:14 UTC] bobsledbob at yahoo dot com
I'm having a hard time understanding how bug 13243 has anything to do with this bug.
 [2001-09-26 11:17 UTC] bobsledbob at yahoo dot com
Ahh, duplicate of bug 13443.  Thanks!
 [2002-06-18 18:42 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat May 25 21:01:27 2019 UTC