Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

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');

?>

Posted (edited)

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
Posted

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.

Posted

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();

Posted

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

Posted

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

Posted

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

Layout Name: 'Web Registration Information'

FileName: 'Web Registration Information.fp7'

Posted

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

Posted

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.

Posted

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

Posted

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

Posted

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();

}

Posted

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

Posted

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

Posted

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

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