2 Replies Latest reply on Sep 19, 2012 9:47 PM by megharajdeepak

    Service is passing Null when value is not Null

    iamcootis Level 1

      I have a PHP Service that is inserting a user into the database. The PHP function looks like this:

       

      public function insertUser($item) {
          $stmt = mysqli_prepare($this->connection,
               "INSERT INTO users ( fb_id, name, birthday, firstName,
                    gender, hometown, lastName, location, username,
                    link,age) 
                    VALUES (?, ?, ?, ?, ?, ? , ?, ?, ?, ?, ?)");
          $this->throwExceptionOnError();
      
          mysqli_bind_param($stmt, 'ssssssssssi', 
                    $row->fb_id, $row->name, $row->birthday, $row->firstName,
                    $row->gender, $row->hometown, $row->lastName, $row->location, $row->username,
                    $row->link,$row->age);
          $this->throwExceptionOnError();
      
          mysqli_stmt_execute($stmt);
          $this->throwExceptionOnError();
      
          $autoid = mysqli_stmt_insert_id($stmt);
      
          mysqli_stmt_free_result($stmt);
          mysqli_close($this->connection);
      
          return $autoid;
        }
      

       

      When I introspect the service it creates insertUser(item:Object) : Object

       

      When I try to test the operation I create an object that looks like this:

      {
           fb_id:"12",
           name:"A",
           birthday:"2010-12-12",
           firstName:"A",
           gender:"male",
           hometown:"A",
           lastName:"A",
           location:"A",
           username:"A",
           link:"A",
           age:30
      }
      

       

      I get this error:

       

       

      InvocationTargetException:There was an error while invoking the operation. Check your server settings and try invoking the operation again. 
      
      Reason: Server error MySQL Error - 1048: Column 'fb_id' cannot be null #0 C:\wamp\www\phpTest\UserService.php(351): UserService->throwExceptionOnError() #1 [internal function]: UserService->insertUser(Object(stdClass)) #2 [internal function]: ReflectionMethod->invokeArgs(Object(UserService), Array) #3 C:\wamp\www\ZendFramework\library\Zend\Server\Reflection\Function\Abstract.php(368): call_user_func_array(Array, Array) #4 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(356): Zend_Server_Reflection_Function_Abstract->__call('invokeArgs', Array) #5 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(356): Zend_Server_Reflection_Method->invokeArgs(Object(UserService), Array) #6 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(550): Zend_Amf_Server->_dispatch('insertUser', Array, 'UserService') #7 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(626): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http)) #8 C:\wamp\www\FacebookUserStatusAIR-debug\gateway.php(69): Zend_Amf_Server->handle() #9 {main} 

       

       

      Any idea what I am doing wrong? Apparently it thinks the values are NULL when they are not.