tags:

views:

25

answers:

2

Hi,

checkdnsrr only works for dot com domains?

If I use live.com (or any existing dotcom), the checkdnsrr returns a value of 1 (TRUE), but it always return a empty string for an existing dot net/org. It does not matter if the check is for A or MX or NS... records. Is the syntax correct or something else?

<?php
$dom ="live.net";
$check = checkdnsrr($dom,'NS');
echo "live $check test ";
?>

TIA

A: 

The code you pasted works for me (TM).

Check your system DNS settings.

Borealid
Are you sure it shows "live 1 test" instead of just "live test"?
Jamex
+1  A: 

checkdnsrr() doesn't return a string at all, it's a BOOL function, so either's true/false. Printing bools out directly is bad practice, because FALSE doesn't get turned into a 0 the way TRUE becomes 1. It's cast into an empty string and so is invisible.

At least change your check into something like:

echo "$dom test: " . ($check ? 'TRUE' : 'FALSE');

and get a proper 'true'/'false' text output.

That being said, live.com and live.net both resolve fine here for all sorts of DNS record types. I'd suggest using 'host or nslookup or dig on the server you're testing this from to see what they're getting for responses. PHP should be using the same resolver as those tools are.

Marc B
Thanks Marc, I know that it is a boolean function, but I think there is something unexplained going on with my network connection. It is interesting that dotcom is the only tld that works for me. Thanks for the confirmation.
Jamex