Jump to content

Working with dns_get_record, this is really killing me


ankur0101

Recommended Posts

Hi

I have 2 problems

 

1) I am making a script which will show NS records i.e.

NS1 -- blah blah

NS2 -- blah blah

 

This is what I have done

 

$domain_name = $_POST[domainbox]; // From text Box
$dns = dns_get_record($domain_name, DNS_NS);
$ns_1 = $dns['0'];
echo $ns_1['taget']; // This means NS1 = blah blah

 

I did this because when we do echo of

 $dns = dns_get_record($domain_name, DNS_NS), out put is 

Out put is

Array
(
    [0] => Array
        (
            [host] => yourdomain.com
            [type] => NS
            [target] => ns1.yourdomain.com
            [class] => IN
            [ttl] => 70144
        )

    [1] => Array
        (
            [host] => yourdomain.com
            [type] => NS
            [target] => ns2.yourdomain.com
            [class] => IN
            [ttl] => 70144
        )

)

 

But it is not showing any output. My brain is screwed up, didnt found anything on google

 

2) If a domain have 4 or 8 i.e. more than 2 name servers, then how to do its output ?

I have noticed 2 errors, your $_POST[domainbox]; should be $_POST['domainbox'];

 

also you have mispelled target in your echo statement, if you want to print all the name servers print the array out in a foreach loop

 

$domain_name = $_POST['domainbox']; // From text Box
$dns = dns_get_record($domain_name, DNS_NS);
foreach ($dns as $record) {
echo $record['target']."<br/>";
}

 

I have tested the code and it works

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.