3 Replies Latest reply on Nov 5, 2008 6:21 AM by kalle_samuelsson

    Create record in Filemaker with PHP

    Rubi

      Title

      Create record in Filemaker with PHP

      Your post

      Hi!

       

      I write you again because I have another problem. I need to create a record in my Filemaker database, but when I execute the command it shows an error that starts like that:

       

      filemaker_error Object ( [_fm] => filemaker_implementation Object ( [V73ee434e] => Array ( [charset] => utf-8 [locale] => en [logLevel] => 3 [hostspec] => http://192.168.1.16 [recordClass] => FileMaker_Record [prevalidate] => [database] => Gestor de ordenes.fp7 [username] => api [password] => api ) [Vea4b3413] => [V9a3dcbce] => ) [error_message_prefix] => [mode] => 1...

       

      ... and continuous. I need to solve this problem,but I don't know how to do it.

       

       

      Thank you.

      Greetings. 

        • 1. Re: Create record in Filemaker with PHP
          kalle_samuelsson
            

          Hi.. good thinking to paste the filemaker_error Object but it is not enough to help you. Show us your PHP-code and give us the errorcode or errormessage returned in the filemaker_error Object. It is returned futher down.. below the part where you truncated the text.

           

          Also be aware that the IP-adress, username and password are visible in the filemaker_error Object. Replace atleast the username and password with *** or people will be able to access you database.

          • 2. Re: Create record in Filemaker with PHP
            Rubi
              

            Hi, thank you for your request. The code is:

             

             

             function insertar_ordenes($obj,$datos){
                $res = array();
                $cont_datos = count($datos);
                for($i=0; $i<$cont_datos; $i++){
                
                           $addrequest =& $obj->newAddCommand('ordenesFacturacion', array('id orden' =>'3000','id factura' => '25','serie' => 'serie','estado' => 'estado','importe con iva' => '15','importe facturado' => '15','IMPORTE IVA' => '15','importe en € pendiente' => '15','fecha factura' => '','Observaciones COBRO' => 'obs'));
                    //Validate all fields
                    $result = $addrequest->execute();
                    print_r($result);
                 }

            return $result ;

             

             

            and the complete error is:

             

            filemaker_error Object ( [_fm] => filemaker_implementation Object ( [V73ee434e] => Array ( [charset] => utf-8 [locale] => en [logLevel] => 3 [hostspec] => http://192.168.1.16 [recordClass] => FileMaker_Record [prevalidate] => [database] => Gestor de ordenes.fp7 [username] => api [password] => api ) [Vea4b3413] => [V9a3dcbce] => ) [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => [message] => Field Not Found [userinfo] => [backtrace] => Array ( [0] => Array ( [file] => c:\apache\htdocs\econet\apiFM\lib\FileMaker\Error.php [line] => 50 [function] => pear_error [class] => pear_error [type] => :: [args] => Array ( [0] => Field Not Found [1] => ) ) [1] => Array ( [file] => c:\apache\htdocs\econet\apiFM\lib\FileMaker\Implementation\LayoutImpl.php [line] => 34 [function] => filemaker_error [class] => filemaker_error [type] => -> [args] => Array ( [0] => filemaker_implementation Object ( [V73ee434e] => Array ( [charset] => utf-8 [locale] => en [logLevel] => 3 [hostspec] => [recordClass] => FileMaker_Record [prevalidate] => [database] => Gestor de ordenes.fp7 [username] => [password] => ) [Vea4b3413] => [V9a3dcbce] => ) [1] => Field Not Found ) ) [2] => Array ( [file] => c:\apache\htdocs\econet\apiFM\lib\FileMaker\Layout.php [line] => 87 [function] => getfield [class] => filemaker_layout_implementation [type] => -> [args] => Array ( [0] => importe en € pendiente ) ) [3] => Array ( [file] => c:\apache\htdocs\econet\apiFM\lib\FileMaker\Implementation\Command\AddImpl.php [line] => 36 [function] => getfield [class] => filemaker_layout [type] => -> [args] => Array ( [0] => importe en € pendiente ) ) [4] => Array ( [file] => c:\apache\htdocs\econet\apiFM\lib\FileMaker\Command.php [line] => 126 [function] => execute [class] => filemaker_command_add_implementation [type] => -> [args] => Array ( ) ) [5] => Array ( [file] => c:\apache\htdocs\econet\apiFM\ordenes.php [line] => 15 [function] => execute [class] => filemaker_command_add [type] => -> [args] => Array ( ) ) [6] => Array ( [file] => c:\apache\htdocs\econet\sincronizar\sincronizacion2.php [line] => 38 [function] => insertar_ordenes [args] => Array ( [0] => filemaker Object ( [_impl] => filemaker_implementation Object ( [V73ee434e] => Array ( [charset] => utf-8 [locale] => en [logLevel] => 3 [hostspec] => [recordClass] => FileMaker_Record [prevalidate] => [database] => [username] => [password] => ) [Vea4b3413] => [V9a3dcbce] => ) ) [1] => Array ( [0] => Array ( [idOrdenFacturacion] => 2007 [idFactura] => 9 [estado] => 9 [serie] => 9 [importeFacturado] => 9 [importeConIva] => 9 [importeIva] => 9 [importePendiente] => 5 [fechaFactura] => [fechaEmision] => 2007-01-01 00:00:00 [observacionesCobro] => C ) [1] => Array ( [idOrdenFacturacion] => 2008 [idFactura] => 8 [estado] => 8 [serie] => 8 [importeFacturado] => 8 [importeConIva] => 8 [importeIva] => 8 [importePendiente] => 8 [fechaFactura] => [fechaEmision] => 2008-01-01 00:00:00 [observacionesCobro] => C ) ) ) ) ) [callback] => )

             

            Thanks a lot. I hope you can help me.

            Bye! 





            • 3. Re: Create record in Filemaker with PHP
              kalle_samuelsson
                

              Hi again!

               

              The error reported from FileMaker when the command is executed is "Field not found" wich often means that a field you request does not exist on your the layout in the request command. In you case however my guess is that you have an invalid charater in one of you fieldnames. The field that is reported as missing on your layout is "importe en € pendiente".

               

              First make sure that the field "importe en € pendiente".  is present on the layout "ordenesFacturacion". If it is there and it still does not work, try removing the "€" char from the fieldname in Filemaker and dont forget to remove it in the PHP code to. Then it should work.

               

              Hope it helps