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.

connect php (on linux server) to database (filemaker server)

Featured Replies

Hi I have a

- Centos Linux Server where php is running fine. (10.1.1.240

- Window Server 2008 where Filemaker Server 11 is installed (10.1.1.201)

- Database name is bookstore.fp7

What would be the database connection in php?

Thank you

Set the Extended Privileges in Accounts and Privileges to allow access via php web publishing. The PHP code must have this code:


define('FM_HOST', '127.0.0.1');//insert actual servername or IP address

define('FM_FILE', 'bookstore');

define('FM_USER', 'username'); //insert actual username

define('FM_PASS', 'myPassword'); //insert actual password

include('filemaker.php'); //include actual path to filemaker API files

$fm=new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

For more information on interfacing, download the Filemaker Custom Web Publishing Guide

  • Author

thanks doughemi.

Are php codes same as php-mysql if i want to select the table and display data from this FM database?

Similar but not identical. The Web Publishing Guide defines them. One thing to always bear in mind is that the FileMaker PHP API is focused on layouts, not tables

  • Author

I am getting error message saying: Error: Communication Error: (7) couldn't connect to host

I can successfully ping from the linux host to this FM server.

I have used following php script.


<?php

error_reporting(E_ALL);

define('FM_HOST', '10.1.10.231');//insert actual servername or IP address

define('FM_FILE', 'questionnaire');

define('FM_USER', 'web'); //insert actual username

define('FM_PASS', 'web'); //insert actual password

include('FileMaker.php'); //include actual path to filemaker API files

$fm=new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

?>

	<?php

  

		/**

		 * We need the ID of the 'Active Questionnaire' in the database.

		 * Since there can only be one active questionnaire at a time,

		 * this can be retrieved from the database by using a simple 'find all' command.

		 */

	  

		#Create the 'find all' command and specify the layout

		$findCommand =& $fm->newFindAllCommand('active_Questionnaire');

	  

		#Perform the find and store the result

		$result = $findCommand->execute();

	  

		#Check for an error

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

			echo "<p>Error: " . $result->getMessage() . "</p>";

			exit;

		}

	  

		#Store the matching records

		$records = $result->getRecords();

	  

		#Retrieve and store the questionnaire_id of the active questionnaire

		$record = $records[0];

		$active_questionnaire_id =  $record->getField('questionnaire_id');

	  

		/**

		 * To get the name of the active questionnaire, we can perform another find

		 * on the 'questionnaire' layout using the $active_questionniare_id.

		 */

	  

		#create the find command and specify the layout

		$findCommand =& $fm->newFindCommand('questionnaire');

	  

		#Specify the field and value to match against.

		$findCommand->addFindCriterion('Questionnaire ID', $active_questionnaire_id);

	  

		#Perform the find

		$result = $findCommand->execute();

		#Check for an error

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

			echo "<p>Error: " . $result->getMessage() . "</p>";

			exit;

		}

	  

		#Store the matching record

		$records = $result->getRecords();

		$record = $records[0];

	  

		#Get the 'Questionnaire Name' field from the record and display it

		echo "<p>Thanks for taking the " . $record->getField('Questionnaire Name') . "</p>";

	  

		#Get the 'Description' field from the record and display it

		echo "<p>Questionnaire Description: "  . $record->getField('Description') . "</p>";

  

	?>

Make sure port 5003 is open in any firewall between the two servers. Also, your code looks for FileMaker.php in the same directory as the php file (it usually is in a subfolder named "filemaker", so adjust the include() statement accordingly).

In your original post, you say the Filemaker Server is on 10.1.1.201, but your code says it's on 10.1.10.231 .

  • Author

on original post i gave some different ip, FM server is 10.1.10.231.

FileMaker.php is in the root.

FM Server has firewall disabled. There is not firewall between servers.

From Linux server I can telnet to FM Server on port 5003.

Are you sure you've actually configured CWP on the FM Server?

  • Author

Hi,

My PHP scripts will be in Apache on my Linux Server. I have copied FileMaker API on the root where my php scripts page are. This php page will be accessing database from FileMaker Server. As I will only be accessing database from FileMaker Server, Do I still install/configure CWP on FileMaker server.

Isnt CWP must be installed if I want to have php pages on FileMaker Server?

In order to communicate with FileMaker via its XML engine (which the PHP API does) you MUST install the "Custom Web Publishing Engine" (CWPE) - this component is a connecting service that processes inbound XML over a target web port / path, passes a command or series of commands to FileMaker server which then returns its response to the component which then in turn returns the XML.

This is a complete and distinct component of FileMaker needs to be installed regardless of whether your PHP application sits on that server or somewhere entirely different.

Components:

1) FileMaker Server

2) FileMaker CWPE

3) Your PHP engine

Each component can sit on a separate server though 1+2 are normally located on the same machine.

  • Author

Hi Genx,

To enable the components I started the deployment Assistant

selected Yes, enable web publishing

ticked XML and PHP (No, use my existing installation of the PHP engine)

on Deployment type which one do i select? Single Machine or Two machines.

If i select two machines and enter the IP Address of Linux server on Lookup box, there is an error which says "Error encountered while doing lookup"

di-8T1N.jpg

Deploy the FileMaker Server and the Web Publishing role to a single machine, the linux box has nothing to do with FileMaker itself and doesn't need to be configured.

  • Author

Genx

thank you very much for your help, I connect successfully now.

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.