Web Advertising - Secured Loans - Credit - Loans - Loans

PDA

View Full Version : Help with Net_DNS plz


Katanius
Jun 7th 2007, 6:50 pm
Hi,
I need to make an mx request to a host sto i installed the Net_DNS package. I copy pasted this code from the developers site:
<?php

// include class file
include("Net/DNS.php");

// create object
$ndr = new Net_DNS_Resolver();

// query for IP address
$answer = $ndr->search("www.cnet.com", "MX");

// print output
$answer->answer[0]->display();
echo "<br>";
$answer->answer[1]->display();
?>


I execute it and i get the following two errors:

Notice: Trying to get property of non-object in C:\Program Files\Apache Group\Apache2\htdocs\dns\dnsspec.php on line 13

Fatal error: Call to a member function display() on a non-object in C:\Program Files\Apache Group\Apache2\htdocs\dns\dnsspec.php on line 13

What does this mean? How can i fix it and make it work?

ansi
Jun 7th 2007, 8:46 pm
Hi,
I need to make an mx request to a host sto i installed the Net_DNS package. I copy pasted this code from the developers site:
<?php

// include class file
include("Net/DNS.php");

// create object
$ndr = new Net_DNS_Resolver();

// query for IP address
$answer = $ndr->search("www.cnet.com", "MX");

// print output
$answer->answer[0]->display();
echo "<br>";
$answer->answer[1]->display();
?>


I execute it and i get the following two errors:

Notice: Trying to get property of non-object in C:\Program Files\Apache Group\Apache2\htdocs\dns\dnsspec.php on line 13

Fatal error: Call to a member function display() on a non-object in C:\Program Files\Apache Group\Apache2\htdocs\dns\dnsspec.php on line 13

What does this mean? How can i fix it and make it work?

you need to initiate the object in order to use it. www.php.net/oop

what is $ndr? it should be initiated. $ndr = new ClassName;

HypertextFever
Jun 7th 2007, 11:55 pm
Perhaps the pathing is invalid in your include of the DNS.php script.

From your .php file (the one with the code you've posted here) is the DNS.php file located in a subfolder named "Net" (case sensitive)?

Katanius
Jun 8th 2007, 4:08 pm
this is my include path: ;include_path = "C:\PHP5\PEAR"
and this is my php instalation dir:
C:\PHP5
the package is installed in:
C:\PHP5\PEAR\Net
and i use php5

The dns.php file is part of the pear package.

The package documentation says that it cannot be called statically. I thought that $ndr = new Net_DNS_Resolver(); initiates the object. Net_DNS_Resolver is the name of the object. should it be something like:
DNS::Net_DNS_Resolver($ndr); or DNS->Net_DNS_Resolver($ndr); Im kind of confused because php4 and 5 initiate objects difrently and im not very familiar with objects and classes.

ansi
Jun 8th 2007, 9:27 pm
yeah you are initiating it, i must have overlooked that the first time. apologies.

Katanius
Jun 9th 2007, 4:56 pm
so any ideas why its not working? should it be initiated diferently?

ansi
Jun 9th 2007, 5:30 pm
not quite sure here. pear and i dont get along to well.