Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FileMaker 12 PHP cannot create new record

Featured Replies

Hi, I'm running FileMaker 12 on a Filemaker 13 server.  I'm able to sort and delete records, but cannot edit or create new records.  Here is a snippet of my code for entering a new record, any help would be appreciated!

<?php include('start.php');?>

<?php

$request = $fm->newAddCommand('my_layout');
$request->setField('FirstName', $_POST['FirstName']);
$result=$request->execute();

?>

<form action="InsertRecordSimple.php" method="post" name="Insert">
<table border="1">
  <tr>
    <td>First Name </td>
    <td><input name="FirstName" type="text" id="FirstName" /></td>
 
 
  </tr>
</table>
<p>
<input name="insert" type="submit" id="save" value="Save" input />
<input name="insert" type="submit" id="cancel" value="Cancel" input />
</form>

 

First, make sure that you are using the FM 13 API files.  I had problems when I used FM12 API when I upgraded to FMS13.

Add 

ini_set('display_errors', '1');

 to the beginning of your php code to help troubleshooting (comment it out for production).

Your php should check for  whether the form has been submitted before doing anything with $_POST data:

if(isset($_POST['insert'])){
	$request = $fm->newAddCommand('my_layout');
	$request->setField('FirstName', $_POST['FirstName']);
	$result=$request->execute();
	if(FileMaker::isError($result)){
		echo $result->getMessage();
	}
}

Otherwise, you will get an invalid index error. (the ini_set statement above will display that for you). The last if() allow you to see what errors the API is reporting.

If these do not help you pinpoint the error, post your findings.

  • Author

Hi doughemi, thanks for your reply.  Sounds right, How do I know if i have the FMS 13 API files and where might I get them If I don't?

 

thanks!

No way to tell, that I know of, but I haven't dug into the files themselves.

They're located in <yourVolume>/Library/Filemaker Server/Web Publishing.  I just went ahead and replaced the ones in my directory with these.

  • Author

Thanks doughemi, it's crazy, I can sort and delete records but can't edit or create new ones.  Plus deleting doesn't ask for a password as it should with my security protocol.  Where did you get the proper  FMS 13 API files?

They're installed in the folder I mentioned when FMS is installed, in a zip named "FM_API_for_PHP_Standalone"

  • Author

Thanks again for your help.  My database is being hosted by FMPHosting server, so I don't know where /Library/Filemaker Server/Web Publishing is or how FM_API_for_PHP_Standalone works.  I'm a novice and am reading 2 books on FileMaker and PHP.   Everything works except editing and creating new records.  Thanks for you previous code examples, but my results didn't change.

Contact the hosting service to see if they will send you a copy of the API.

What error messages were shown after you added the error trapping code?

Does the privilege set for the php username allow record creation?

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.