Welcome to WebmasterWorld Guest from 23.22.220.37

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

dns get record occasionally returns an empty array

Nameservers

     
12:02 pm on Mar 28, 2013 (gmt 0)

Preferred Member from GB 

10+ Year Member Top Contributors Of The Month

joined:July 25, 2005
posts: 387
votes: 7


Hi,

Just a simple script designed to return nameserver info. In 99.9% cases it works ok, only occasionally it returns an empty array.

<?php
$nsresult = dns_get_record("example.com", DNS_NS);
echo $nsresult[0]['target'];
echo "<br/>";
echo $nsresult[1]['target'];
?>


if I print the result for the whole $nsresult variable of a faulty domain, I get this on the screen:

Array ( )


When I look up the domain's nameservers via Whois and try to ping them, they will respond, so the nameservers aren't down. Is it some sort of a misconfiguration on the nameserver? Is there another way to make them respond?
Thanks!
8:17 pm on Apr 2, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


Does your script always fail on this problematic domain?

Is the problematic domain on the same server as your script (shared hosting)? In this case dns_get_record() can apparently return an empty array when attempting to get the nameservers, according to this comment on PHP.net: [php.net...]
11:07 am on Apr 12, 2013 (gmt 0)

Preferred Member from GB 

10+ Year Member Top Contributors Of The Month

joined:July 25, 2005
posts: 387
votes: 7


@penders,

Yes, it will fail on the same domain over and over again. The poblematic domain is not on the same server as my script. Out of 100 randomly selected domains, 1 to 3 will always return an empty array.
11:25 am on Apr 12, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


For these problematic domains can you retrieve any DNS information?
11:00 pm on Apr 12, 2013 (gmt 0)

Preferred Member from GB 

10+ Year Member Top Contributors Of The Month

joined:July 25, 2005
posts: 387
votes: 7


No, not with dns_get_record regardless of what type parameter I put in the brackets. So, I was wondering if there was an alternative.