tags:

views:

33

answers:

2

The code is as follows:

$domain = "fosajfjdkgdajfhsd.com";
$check1 = checkdnsrr($domain, "MX");
$check2 = checkdnsrr($domain, "A");
$check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
$check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
die("{$check1} - {$check2} - {$check3} - {$check4}");

However when I check the output to see what it's returning, I get this:

 - 1 - 1 - 

The domain obviously wouldn't exist, so I don't understand why checking the A record is returning true and checking the MX result doesn't give me anything at all. I don't understand what's going wrong here.

+1  A: 
$ dig fosajfjdkgdajfhsd.com

; <<>> DiG 9.6.0-APPLE-P2 <<>> fosajfjdkgdajfhsd.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39121
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;fosajfjdkgdajfhsd.com.     IN  A

;; ANSWER SECTION:
fosajfjdkgdajfhsd.com.  0   IN  A   208.69.32.132

;; Query time: 121 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Wed Apr  7 00:59:59 2010
;; MSG SIZE  rcvd: 55

EDIT: Check your DNS provider. Nowadays, lots of them will return their own A record so they can put ads in front of you eyes if the domain can't be resolved. Breaks DNS, but pays the bills.

Fred
Ok, so typing random letters doesn't work. But I've been trying all sorts of other combinations and they all return the same result. I tried "gfsgfghghjggdajfhsd.bite" which cannot possibly exist because .bite is not even a valid domain extension, but I still get true for the A record.
animuson
+1, ISPs like Time Warner Cable (RoadRunner) by default give you a landing page if you try to return a domain that doesn't exist. I would be curious to see the dig output from your box, as Fred has provided. ($check2 returns false for me, on my work connection.)
Adam Backstrom
+1  A: 

Ok, so after browsing through all of the examples in the PHP.net documentation for checkdnsrr() I figured out that for A records you are still required to append a '.' to the end of the domain in order to check it validly. I figured PHP would automatically do that kind of thing for you, but whatever works. Results are as expected now.

animuson
Hah, I just left a comment with that suggestion. I should have posted it as an answer ;)
zombat
Yes you should have, lol. I noticed it there after posting this.
animuson