AnsweredAssumed Answered

PHP API and "undefined method" error

Question asked by cmbehr on Nov 15, 2011
Latest reply on Jan 4, 2012 by cmbehr

I have a few forms on my website that save data to FM databases using the Filemaker PHP API. They work perfectly most of the time. But sometimes most of the forms stop being able to save the form data to a new record. The error looks like this:


Fatal error: Call to undefined method FileMaker_Command_Add::execute()


The relevant lines of code are:


$newRecord =& $fm->newAddCommand('Data_Entry', $formdata);


$result = $newRecord->execute();


(Data_Entry is the layout name and $formdata is an array whose keys are the field names and whose values are the data I want to save in the new record.)


This is driving me crazy on so many levels! I know the Filemaker.php library is getting loaded, because the form loads fine, with valuelist data appearing properly. And I'm using "require_once" to include it, so if the file wasn't found, the script would fail there. So it can't be permissions on the API files or anything like that. It's a PHP error, so maybe it doesn't even have anything to do with Filemaker, but I'm not sure where else to look.


The forms work perfectly for days at a time, then with no change to the code, suddenly fail. Once a form fails, it continues to throw the error until it suddenly starts working again, with no obvious trigger (typically a day or two later). Restarting the Filemaker server doesn't fix it. When one form fails in this manner, most of the others do too (all different databases), but one in particular has never failed. (The code is essentially the same for all.) Forms that edit records, rather than saving new ones, continue working, even when they edit records in the same database where I can't create a new record.


FM Server 11 on Mac 10.6.8 & Apache. PHP 5.1.2 on a different server.


I'd appreciate any suggestions where to go from here.