Jump to content
Server Maintenance This Week. ×

FileMaker 12 PHP cannot create new record


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

Recommended Posts

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>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This topic is 3165 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.