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 ?

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.