Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

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

Posted

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.

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