gethostbyname function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ian Wright
Forum Newbie
Posts: 3
Joined: Thu Apr 14, 2005 1:17 pm
Location: Staines, Middlesex

gethostbyname function

Post by Ian Wright »

After transferring my web access from ADSL to SDSL gethostbyname() fails. The code worked fine on the ADSL line.
The error message code reads:
PHP Warning: fsockopen(): php_network_getaddresses: gethostbyname failed
in <my PHP program> on line 29
PHP Warning: fsockopen(): unable to connect to
<domain name>:80 in <my PHP program> on line 29
Only two things have been changed between working and not working: (1) SDSL line for ADSL line (2) SDSL modem for ADSL modem.
Here's the code fragment:

Code: Select all

function pullpage( $host, $usepath, $postdata = &quote;&quote; ) {
	# open socket to filehandle(epdq encryption cgi)
	$fp = fsockopen( $host, 80, $errno, $errstr, 60 );
	# check that the socket has been opened successfully
	if( !$fp ) {
		$errorString = &quote;<p>$errstr ($errno)</p>&quote;;
		$errorStatus = true;
	}
Any suggestions for a fix for gethostbyname would be welcome.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Are you behind a firewall or proxy?
Ian Wright
Forum Newbie
Posts: 3
Joined: Thu Apr 14, 2005 1:17 pm
Location: Staines, Middlesex

Post by Ian Wright »

Firewall: that which is built into my SDSL modem. It is open inbound on port 80 only.
Ian Wright
Forum Newbie
Posts: 3
Joined: Thu Apr 14, 2005 1:17 pm
Location: Staines, Middlesex

Post by Ian Wright »

Problem resolved.
For the record, the ADSL model set the LAN address of the server, but the SDSL modem does not have that feature, so the server's network configuration was set with a fixed network IP address. That in turn disabled the automatic DNS, so gethostbyname() didn't have anything to refer to. Fix was to enter the modem/gateway IP address into the server's LAN configuraton. Easy when you know what to look for!
Post Reply