Jump to content
Sign in to follow this  

Unable to connect to FileMaker from external PHP (CodeIgniter) after upgrade to

Recommended Posts

We have an export job that grabs and worked flawlessly up until an upgrade this last weekend.

We upgraded from 10 to 11 and all the subsequent updates.

Basically the user specifies a date range on our external website, which then hits the code igniter framework (on the internal web server) to instantiate FileMaker.php and grab the records and serve them back to the external website.

Like I said, this all worked well prior to our upgrade over the weekend.

I JUST inherited this whole system, I know very little about FileMaker but have been reading and testing. Sample FileMaker code works, is able to list databases.

Parts involved:

CodeIgniter Framework


Two web servers: Filemaker web server (db.mydomain.net) and client web server (www.mydomain.com)

Now, when attempting to perform the export we get a CodeIgniter formatted general error that the connection to the database was closed unexpectedly. In other instance we get Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

Am I missing something obvious? As a FileMaker n00b I'm sure I probably am, but your feedback would be very helpful. I'll seriously paypal you some beer money :-)

Here is my controller code (which is unchanged and was working just fine prior to the upgrade:


class Paid_calendar extends Controller {

protected $fm, $main_menu, $current_only;

function __construct()






$this->fm = new FileMaker('IssueAds Index', 'http://db.mydomain.net' 'phpuseraccount', 'thepassword');

$this->main_menu = new FileMaker('Main Menu', 'http://db.mydomain.net' 'phpuseraccount', 'thepassword');


$this->current_only = false;

//$this->load->model('photo', '', true);


public function currentOnly(){

$this->current_only = true;



function index()


$issue_data = $this->Event->getCurrentIssue();

$current_issue = $issue_data->display;


echo "Starting: ".date_create()->format('m-d-Y h:i:s A')."\n";

echo "Issue".$current_issue."\n";

if($current_issue == "16.50" || $current_issue == "16.49"){

$current_issue = "16.51";


//$layout =& $this->fm->getLayout("Issue Ad Search");

//print_r(array_keys($layout->getFields() ) );

$findCommand =& $this->fm->newFindCommand('Issue Ad Search');


$findCommand->addFindCriterion("Issue ID", "{$current_issue}");



$findCommand->addFindCriterion("Issue ID", ">={$current_issue}");


$findCommand->addFindCriterion("Ads::Ad Code ID", '69...99');

//$findCommand->addFindCriterion("cIsActive", 'Active');

$result = $findCommand->execute();

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

echo "Error: " . $result->getMessage() . "\n";



echo $result->getFetchCount();

$records = $result->getRecords();

$issues = array();

$ad_codes = array();

$paid_events = array();

foreach ($records as $record) {

$out = new StdClass();

$out->is_active = $record->getField("cIsActive");

$out->name = $record->getField("Ads::Field_Headline");

$out->description = $record->getField("Ads::Field_Ad Copy");

$out->ad_code = $record->getField("Ads::Ad Code ID");

$out->issue_display = $record->getField("Issue ID");

//echo $out->issue_display;

if(strlen($out->issue_display) == 4){

$out->issue_display .= "0";


$issue_append = str_replace(".", "", $out->issue_display );

$out->fm_ad_id = $record->getField("Ad ID").$issue_append;

$issues[] = $out->issue_display;

$ad_codes[] = $record->getField("Ads::Ad Code ID");

$paid_events[] = $out;


$issues = $this->Event->getIssueInfo($issues);

$ad_codes = $this->Event->getAdCodeInfo($ad_codes);

foreach($paid_events as $event){

$event->description = str_replace("&lt;", "<", $event->description);

$event->description = str_replace("&gt;", ">", $event->description);

$event->sub_section_id = $ad_codes[$event->ad_code];

$event->start_date = $issues[$event->issue_display]->start_date;

$event->end_date = $issues[$event->issue_display]->end_date;

$event->repeat_type = 'daily';

$event->repeat_frequency = 1;

$event->paid = 1;

$event->all_day = 1;

$event->repetition_id = NULL;

$event->status = 'approved';

$old_event = $this->Event->exists($event->fm_ad_id);

if($event->is_active == false){

if($old_event != false){


echo "Deleted {$old_event->fm_ad_id}\n";







// print_r($event);

if($old_event != false ){

$this->Event->update($event, $old_event);

echo "Updated {$event->fm_ad_id}<br />";




echo "Inserted {$event->fm_ad_id}<br />";


echo "\n";


echo "Regenerating Cache Table\n";

echo system("curl -f http://www.mydomain....rateCacheTable");

echo "Cache Table Complete\n";

echo "Complete";



/* End of file welcome.php */

/* Location: ./system/application/controllers/welcome.php */

Share this post

Link to post
Share on other sites

I don't think this is necessary since you're not using CodeIgniters database features.


If this code is running on the FileMaker server, I'd use instead of db.mydomain.net. (I wouldn't use localhost, because I've experienced speed issues on Windows using this).

Add another echo to this section, so you know if this is where the code is exiting:

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

    echo "error with FileMaker result"; // add this line

    echo "Error: " . $result->getMessage() . "n";



echo "no FileMaker Error"; // add this line

Share this post

Link to post
Share on other sites

Thanks Dan for your help. Unfortunately adding some extra echos did not reveal anything. I still get the 324 error.

For what it's worth, I have moved some sample code into the same directory. When I run listDatabases.php I CAN get the list of databases.

However, when I run "compoundFind.php" I get:

"Error: Unable to open file"

So I can get the LIST of databases. But when I try to access a specific database (in this case the sample database) I am unable to get anything. I just get generic errors that the server closed the page, etc.

Any thoughts why this might be happening?



Share this post

Link to post
Share on other sites

Thanks Dan for your help. Unfortunately adding some extra echos did not reveal anything. I still get the 324 error.

Did you see the message "error with FileMaker result", "no FileMaker Error", or no message at all?

Share this post

Link to post
Share on other sites

I'm still getting the 324 error  (net::ERR_EMPTY_RESPONSE) with CodeIgniter Framework and filemaker php api.

Did you solve this problem?





Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Similar Content

    • By jayivan
      I am working on an API integration from FileMaker 17 to Emma. Generally when I work on a new API, I get the curl working on the command line and then translate that into FM. But I've hit a roadblock with one particular API call while my other API calls to Emma are successful. (In the example below, I substituted out sensitive data with all caps.)
      From the command line, the code is:
      curl -u USER:PASS -H "Accept:application/json" -H "Content-type: application/json" -X POST -d '{"fields": {"name_first": "TESTFIRST","name_last": "TESTLAST","eligible": "false","expiration": "@D:2019-06-30"},"group_ids": ["GROUPIDNUMBER"],"email": "EMAIL@EMAIL.COM","opt_in_confirmation": "false"}' "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"
      This command is successful.  The server responds with the individuals' emma id and group confirmation. 
      This fails using Insert from URL within FM though. While eventually I'll use FileMaker fields for an individual record's names, email, and expiration dates, I did not use fields in my testing in order to duplicate the command line exactly. In Insert from URL:
      The URL is "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"
      The curl option is "-u USER:PASS -H \"Accept:application/json\" -H \"Content-type: application/json\" -X POST -d '{\"fields\": {\"name_first\": \"TESTFIRST\",\"name_last\": \"TESTLAST\",\"eligible\": \"false\",\"expiration\": \"@D:2101-06-30\"},\"group_ids\": [\"GROUPIDNUMBER\"],\"email\": \"EMAIL@EMAIL.COM\",\"opt_in_confirmation\": \"false\"}'"
      Can anyone identify the problem or suggest a workaround? My experience with API integration with FM is limited, but anything I could get working via the command line, I've been able to get working within FM until this.
    • By Richard Carlton
      In this Coaches' Corner tip, Richard Carlton challenges you to go learn how to use RESTful services!
      Get up to speed with the FileMaker Pro 16 Video Training Course! 
      Top Rated Course by FileMaker Expert, Richard Carlton.  
      Experience Richard's dynamic and exciting teaching format, while learning both basic, intermediate, and advanced FileMaker development skills. With 27 years of FileMaker experience and a long time speaker at FileMaker's Developer Conference, Richard will teach you all the ins and outs of building FileMaker Solutions.  The course is 50 hours of video content!
      Richard has been involved with the FileMaker platform since 1990 and has grown RCC into one of the largest top tier FileMaker consultancies worldwide. 
      Richard works closely with RCC's staff: a team of 28 FileMaker 
      developers and supporting web designers. He has offices in California, Nevada, and Texas.

      Richard has been a frequent speaker at the FileMaker Developers Conference on a variety of topics involving 
      FileMaker for Startups and Entrepreneurs, and client server integration.

      Richard is the Product Manager for FM Starting Point, the popular and most downloaded free FileMaker CRM Starter Solution.

      Richard won 2015 Excellence Award from FileMaker Inc (Apple Inc) for outstanding video and product creation, leading to business development.

      RCC and LearningFileMaker.com are headquartered in Santa Clara, CA.

      Please feel free to contact us at support@rcconsulting.com
      If you want to explore building iOS apps for iPhone or iPad and deploying those out to the Apple App Store.
      Here is a video introduction to our iOS App Training https://www.youtube.com/watch?v=cVxQe_yAshw
      Looking for FM Starting Point free software download: http://www.fmstartingpoint.com
      For More Free FileMaker Videos Check out http://www.filemakerfree.com
      Visit http://www.learningfilemaker.com for all facets of FileMaker Award Winning Video Training.
      Please Visit Our Channel: https://www.youtube.com/user/FileMakerVideos Please Subscribe While There.

      Please Comment, Like & Share All of Our Videos.

      Feel Free to Embed any of Our Videos on Your Blog or Website.
      Follow Us on Your Favorite Social Media

      Filemaker Pro 16 Training Videos
      FileMaker 16 Videos
      Filemaker Pro 16 Video Course
    • By docasar
      I am trying to connect to our current database with our shipping company so I can update the status of the delivered orders. To do that, I am currently using insert from URL and then parse the code to extract the info I need. However, I believe there should be a cleaner and safer way to do it using webservice.
      So I downloaded the documentation and looks very straightforward to set and I have been able to set up the POST and send it getting the data as XML using POSTMAN (as very well explained here:  http://www.filemakerprogurus.com/filemaker-api-integration-salvatore-coleangelo/ ) and also in the great post by luminfire https://luminfire.com/2017/06/12/curling-filemaker-16/.
      However, when I try the same parameters on my script in filemaker, I get all the time an error saying that something like  "Entry XML Schema/template it is not loaded correctly". Following the documentation of the API I see that on Postman I need to insert on the Body RAW some kind of code that looks like this: 
      <?xml version='1.0' encoding='UTF-8'?>
      <SeguimientoEnviosRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='SeguimientoEnviosRequest.xsd'>
      but I don't know which settings I have to do on my script to make the call work.
      Any suggestions as to where to put this info so the can be passed with the CURL? I am a bit desperate now because I see the amazing possibilities that the interaction with the web service may bring but I can find a way to make it work...
      Thanks a lot for your always invaluable support!!
    • By jpons
      I want to enable the Cloud REST API, but I am afraid that I "dismissed" the notification message that allowed me to do so. How can I enable the RESP API on my cloud instance?
    • By JTSmith
      OK, I'm using FM16 and trying to figure out an API call.  I'm not an expert when it comes to APIs.
      I have a shopify store, and I can use Insert from URL to get the JSON info on each order.  I want to be able to "PUT" and upload parts of the order.  Every order has a "Note" field that I can add notes.  Per the shopify API documentation, to add an order note, you do the following:
      Add Note to order
      PUT /admin/orders/#{id}.json { "order": { "id": 450789469, "note": "Customer contacted us about a custom engraving on this iPod" } }  
      Can someone help me with what I put in the cURL options area?  Any help would be appreciated.  I think I have the URL and Target figured out.  Thank you!!

Important Information

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