Jump to content

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


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

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";

  

	?>

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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