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