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.

How to call a basic hello world filemakescript from PHP

Featured Replies

  • Newbies

All,

 

Trying to run a `hello world` filemaker script using the PHP API. Getting field not found error (105). Doesn't seem to matter if I call a script that exists or not. Any ideas on how to get a basic script working?

Big picture goal is to pass a parameter, do a commit records request and get a return value but first things first, need to execute any script. Sample code below.

Thanks!

Aaron

 

// PHP PAGE
$script_name = "Hello World";
$layout_name = ""; // why does it need a layout?

//when specifying a valid layout name, get error 3 - Command is unavailable (for example, wrong operating system, wrong mode, etc.)

$parameters = null; // basic, matches API code

 

$newPerformScript =& $fm->newPerformScriptCommand($layout_name, $script_name, $parameters);
$result = $newPerformScript->execute();
var_dump($result); die;

 

// FILEMAKER SCRIPT
Script Name: Hello World
#comment
Send Event["aevt"; "odoc"; "success or failure message"]
Open Url["google.com"]
Exit Application

You haven't accessed the database with your PHP script ($fm is undefined in your script):

define('FM_HOST', '127.0.0.1');     //Actual IP address or domain name here
define('FM_FILE', 'YourFileName'); //Actual file name here
define('FM_USER', 'ValidFMAccount');   // Actual account name here
define('FM_PASS', 'ValidUserPassword');  // Actual password for above account here
require_once('Filemaker.php'); //  Be sure to use actual path to Filemaker.php
//
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
//
//  The following code checks that we are connected to the database
//  and if we are not, goes to an error page where a message would be displayed.
//
$accessed = $fm->listLayouts();
if(FileMaker::isError($accessed)){
Header("location:http://Path/to/myErrorPage.php");
exit;
}
 

 

 

The easiest way to do this is to put the above code in an include script and call it at the beginning of your PHP code.

 

A layout name is required because the API is layout-based. (Your script may be dependent on a specific TO, so you have to be in a layout based on that TO).  Although it is irrelevant in this example, a layout name is still required.

 

Your OpenURL step requires the whole URL (http://www.google.com)

 

EDIT:  Make sure that PHP access is allowed for the account name you specify in the PHP script.

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.