Jump to content
Server Maintenance This Week. ×

Insert record to filemaker db from php


This topic is 4324 days old. Please don't post here. Open a new topic instead.

Recommended Posts

$id = $_POST['familyid'];

$rec = $fm->getRecordById('Family', $id);

if (FileMaker::isError($rec)) {

echo "Error :" .$rec->getMessage()."</br>";

exit;

}

$rec->setField('address', $_POST['addr'] );

$rec->setField('city', $_POST['city'] );

$rec->setField('s_last_name', $_POST['fslastname'] );

$rec->setField('s_gender', $_POST['fsgender'] );

$rec->commit();

The above php code that im using to insert the records to filemaker db from php pages... but some time record not properly stored to filemaker db.. (i have not included the db connection code here)

please help me someone to solve this issue, or if possible share ur mind if you have any alternate idea.... or I need to do any changes with the above code.

Many thanks in advance

Link to comment
Share on other sites

The FileMaker internal Record ID is not necessarily going to be the same as the id field you have created, so getRecordById may not work in this instance.

try


// find the correct record

$id = $_POST['familyid'];

$getrec = $fm->newFindCommand('family');

$getrec->addFindCriterion('ID', $id); //This should be your table's ID field

$found = $getrec->execute();

// get FileMaker's record ID

$rec = $found->getRecords();

$recid = $rec[0]->getRecordId();

// edit record

$change = newEditCommand('family', $recid);

$change->setField('address', $_POST['addr'] );

$change->setField('city', $_POST['city'] );

$change->setField('s_last_name', $_POST['fslastname'] );

$change->setField('s_gender', $_POST['fsgender'] );

$result = $change->execute();

  • Like 1
Link to comment
Share on other sites

This topic is 4324 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.