May 28, 200718 yr 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'); ?>
May 28, 200718 yr 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 May 28, 200718 yr by Guest
May 29, 200718 yr 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.
May 31, 200718 yr 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();
June 1, 200718 yr 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
June 3, 200718 yr <?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.
June 4, 200718 yr Author No the spaces are just caused by pasting code into the forums. It happens all the time.
June 4, 200718 yr No I mean actual spaces in your layout / FileName ... Layout Name: 'Web Registration Information' FileName: 'Web Registration Information.fp7'
June 4, 200718 yr Your script doesn't have any web incompatible script steps in it does it? -- like dialogs, emails, windows etc.
June 5, 200718 yr Author I know it better to connect words with underscores but it hasnt caused a problem so far.
June 5, 200718 yr Author Its a very simple script for testing purpsoes - just "New Record/Request" which is web compatible.
June 6, 200718 yr error handling in FX.php if (FX::isError($myReturnedData)) { ...handle errors gracefully here... }
June 6, 200718 yr 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.
June 6, 200718 yr 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
June 7, 200718 yr 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
June 8, 200718 yr 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(); }
June 12, 200718 yr 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
June 12, 200718 yr ... Well then everything indicates that the script is being run. Are you 100% sure it's not?
June 13, 200718 yr 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.
June 14, 200718 yr 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
Create an account or sign in to comment