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.

Featured Replies

Hi there,

I am trying to get a php script to trigger a FMPro script called 'New_Record'. Here's what i've got so far but I'm a bit lost:

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$scriptName=$_REQUEST['New_Record'];

$Run_Script=new FX($serverIP,$webCompanionPort,'FMPro7');

$Run_Script->SetDBData('Web Registration Information.fp7','Web Registration Information',$groupSize);

$Run_Script->SetDBPassword('fmsadmin','fmsadmin');

$Run_Script->AddDBParam('-script', $scriptName);

$Run_ScriptResult=$Run_Script->PerformFMScript('New_Record');

?>

Okay, well I only use the FM php api, so i couldn't tell you the first thing about the FX methods... but just a general question, what is $scriptName actually meant to be equal to, and is there any reason your not using $_GET or $_POST? ... and what does the New_record script do anyway (despite its name)

Edited by Guest

  • Author

I'm following the code in FX.php.

Hmmm...

Okay, i suggest you try www.fmwebschool.com/frm -- they are more Fx.PHP orientated around there so you'll probably get a quicker response.

Whenever possible, try to do things in PHP rather than by script.

But the script should trigger with

...

$Run_Script->AddDBParam('-script', 'New_Record');

$Run_ScriptResult=$Run_Script->FMFind();

  • Author

Hi Mark,

Thanks for your reply. Here's the full code with your reccommendation, but no joy yet:

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$Run_Script=new FX($serverIP,$webCompanionPort,'FMPro7');

$Run_Script->SetDBData('Web Registration Information.fp7','Web Registration Information',$groupSize);

$Run_Script->SetDBPassword('fmsadmin','fmsadmin');

$Run_Script->AddDBParam('-script', 'New_Record');

$Run_ScriptResult=$Run_Script->FMFind();

?>

I also tried FindAll but nothing happened.

Cheers,

Steven

<?php

$Run_Script=new FX($serverIP,$webCompanionPort);

$Run_Script->SetDBData('Web Registration Information.fp7','Web Registration Information');

$Run_Script->SetDBPassword('fmsadmin','fmsadmin');

$Run_Script-> AddDBParam('-script','New_Record');

$result=$Run_Script->FMFind();

?>

If the above doesn't work, it could be that you have spaces in your layout / FileName -- try removing those, double check that fmsadmin has all the necessary extended privileges required for fxphp.

  • Author

No the spaces are just caused by pasting code into the forums. It happens all the time.

No I mean actual spaces in your layout / FileName ...

Layout Name: 'Web Registration Information'

FileName: 'Web Registration Information.fp7'

Your script doesn't have any web incompatible script steps in it does it? -- like dialogs, emails, windows etc.

  • Author

I know it better to connect words with underscores but it hasnt caused a problem so far.

  • Author

Its a very simple script for testing purpsoes - just "New Record/Request" which is web compatible.

There's no way to trap for errors with the FX.php class?

error handling in FX.php

if (FX::isError($myReturnedData)) {

...handle errors gracefully here...

}

Lets break this down:

What does the script do? Remember, whenever possible we want to recreate the same functions of a script in PHP.

Show us the steps of your script and we can see if there is anything obvious.

  • Author

The script is just a test script with one step only:

New Record/Request

That's all there is to it.

I just want to get the PHP code right that would activate any script.

Cheers,

Steven

The code we gave is correct:

$Run_Script=new FX($serverIP,$webCompanio nPort,'FMPro7'); 

$Run_Script->SetDBData ('Web Registration Information.fp7','Web Registration Information',$groupSize); 

$Run_Script->SetDBPassword('fmsadmin','fmsadmin ');



$Run_Script->AddDBParam('-script', 'New_Record'); 

$Run_ScriptResult=$Run_Script->FMFind(); 

Therefore we need to check that your script works. If you perform the script in Filemaker does it work?

The only other things I can think of are to check case sensitivity of all code, and perhaps use full quotes around "New_Record".

Perhaps add the following line to your code and report the error code.

echo $Run_ScriptResult['errorCode'];

Good luck

You should really Try two things.

1) Firstly as mlindal suggests: Make sure the script works in FM, that's critical... I wasted a while because i forgot to change my relationships... Anyway, point is just make sure it works there.

2)

Run this:

$Run_Script=new FX($serverIP,$webCompanio nPort,'FMPro7');

$Run_Script->SetDBData ('Web Registration Information.fp7','Web Registration Information',$groupSize);

$Run_Script->SetDBPassword('fmsadmin','fmsadmin ');

$Run_Script->AddDBParam('-script', 'New_Record');

$Run_ScriptResult=$Run_Script->FMFind();

if (FX::isError($myReturnedD ata)) {

echo $myReturnedData->getMessage();

}

  • Author

Sorry but I get nothing when I run the suggested code:

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$Run_Script=new FX($serverIP,$webCompanionPort,'FMPro7');

$Run_Script->SetDBData('Web Registration Information.fp7','Web Registration Information',$groupSize);

$Run_Script->SetDBPassword('fmsadmin','fmsadmin');

$Run_Script->AddDBParam('-script','New_Record');

$Run_ScriptResult=$Run_Script->FMFind();

if (FX::isError($myReturnedData)) {

echo $myReturnedData->getMessage();

}

?>

The New_Record script works fine in FMPro.

Using " " around New_Record instead of ' ' made no diffference.

Adding underscores between the words in the database and layout names made no difference either.

Cheers,

Steven

... Well then everything indicates that the script is being run. Are you 100% sure it's not?

  • Author

If it had run, there would be one more record in the Web Registrations Database and the record count does not change after running the script.

Thanks for trying anyway.

  • Author

Success! The following code worked:

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$Run_Script=new FX($serverIP, $webCompanionPort,'FMPro7');

$Run_Script->SetDBData('Web Registration Information.fp7','Web Registration Information', $groupSize);

$Run_Script->SetDBPassword('fmsadmin','fmsadmin');

$Run_Script->PerformFMScriptPrefind('Perform_New_Record');

$Run_ScriptResult=$Run_Script->FMFind();

?>

The PerformFMScriptPrefind was the right function to use in this case.

I also wondered if the Filemaker script had to begin with a "Perform Script[]" step but Ive tested the 'Perform_New_Record' script via PHP without that step and it works OK.

Cheers,

Steven

Lol, congratulations :o .

Sorry you had to work it out yourself.

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.