0 Replies Latest reply on Jun 15, 2010 11:38 AM by Arnoldski

    Error when adding 2 new records in the database with the filemaker api

    Arnoldski

      Title

      Error when adding 2 new records in the database with the filemaker api

      Your post

      I'm having a problem in php when I call 2 different functions on the same page that add a record in the database.

      These are the 2 functions:


      function setAdressen($values, $recID = false)
      {
      $fm = new FileMaker();
      $fm->setProperty('database', 'adressen_');
      $fm->setProperty('username', '***');
      $fm->setProperty('password', '***');

      if($recID)
      {
      $newEdit =& $fm->newEditCommand('WEB2010', $recID, $values);
      $result = $newEdit->execute();
      }
      else
      {
      $rec =& $fm->createRecord('WEB2010', $values);
      $result = $rec->commit();
      }

      if(FileMaker::isError($result))
      {
      echo "Error in 'setAdressen': " . $result->getMessage() . "<br />";
      echo "Errors: " . $result->getErrorString() . "<br />";
      $fm = NULL;
      exit();
      return false;
      }
      else
      {
      if($recID)
      {
      return true;
      $fm = NULL;
      }
      else
      {
      return $rec->getRecordId();
      $fm = NULL;
      }
      }
      }


      function setLeveringen($values, $recID = false)
      {
      $fm = new FileMaker();
      $fm->setProperty('database', 'leveringen_');
      $fm->setProperty('username', '***');
      $fm->setProperty('password', '***');

      if($recID)
      {
      $newEdit =& $fm->newEditCommand('WEB2010', $recID, $values);
      $result = $newEdit->execute();
      }
      else
      {
      $rec =& $fm->createRecord('WEB2010', $values);
      $result = $rec->commit();
      }

      if(FileMaker::isError($result))
      {
      echo "Error in 'setLeveringen': " . $result->getMessage() . "<br />";
      return false;
      }
      else
      {
      if($recID)
      {
      return true;
      }
      else
      {
      return $rec->getRecordId();
      }
      }
      }

       

      If I call these 2 functions in random order I always get the error: "Field not found".

      If I call the same functions seperately with the same values on a different page I don't get any error.

       

      What seems to be the problem here?

       

       

      Filemaker 10 is installed on the server.