views:

784

answers:

5

I am trying to add a new hello world service to amfphp, I am developing locally

<?php

/**
 * First tutorial class
 */
class HelloWorld {

   /**
    * first simple method
    * @returns a string saying 'Hello World!'
    */
   function sayHello()
   {
       return "Hello World!";
   }

}

?>

when exploring in the amfphp browser i get a "TypeError: Error #1009: Cannot access a property or method of a null object reference." need help...

A: 

You're trying to access a variable/method that's null. The code here is fine so the problem is somewhere else..

Antti
+1  A: 

Is that the entirety of your source code? I'm sure this isn't the problem but just in case, you are opening the ?php tag right?

Here's one of my simple service classes:

<?php

class Products {

    public function __construct() {
     mysql_connect("localhost", "myuser", "mypass");
     mysql_select_db("mydb");
    }
    /** 
    * Retrieves data
    * @returns data
    */
    function getProduct() {
     $sql = 'SELECT * FROM `content_type_product`'; 
     return mysql_query($sql);
    }
}
?>
defmeta
A: 

I am opening the tag, its just ungraceful copy paste...

+2  A: 

I recommend Charles for solving this type of problem, this let's you see what's going across the wire. In your case it's likely something simple as a syntax error in the php file. PHP will output the error information into what the Service Browser expects to be amf-encoded data, wreaking havoc to any parsing it tries. Using Charles you can easily see this and fix it!

grapefrukt
A: 

I agree with grapefrukt... The browser really doesn't give you good information about PHP errors. Charles is a godsend for doing stuff over AMF and I recommend it highly. You'll get information about the request and the result along with any PHP error messages.

Ben Throop