ankur0101 Posted June 1, 2011 Share Posted June 1, 2011 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/ Share on other sites More sharing options...
dragon_sa Posted June 1, 2011 Share Posted June 1, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/#findComment-1223501 Share on other sites More sharing options...
ankur0101 Posted June 1, 2011 Author Share Posted June 1, 2011 OMG These are silly mistakes. Thanks for your help Sir Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/#findComment-1223509 Share on other sites More sharing options...
ankur0101 Posted June 1, 2011 Author Share Posted June 1, 2011 Only problem is it shows in descending order ns4 ns3 ns2 ns1 where it should be ns1 ns2 ns3 ns4 Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/#findComment-1223522 Share on other sites More sharing options...
dragon_sa Posted June 1, 2011 Share Posted June 1, 2011 $domain_name =$_POST['domainbox']; // From text Box $dns = dns_get_record($domain_name, DNS_NS); sort($dns); foreach ($dns as $record) { echo $record['target']."<br/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/#findComment-1223716 Share on other sites More sharing options...
ankur0101 Posted June 2, 2011 Author Share Posted June 2, 2011 Thanks you Sir Quote Link to comment https://forums.phpfreaks.com/topic/238098-working-with-dns_get_record-this-is-really-killing-me/#findComment-1223882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.