Danjmains Posted October 23, 2015 Posted October 23, 2015 Hi, For some reason I can't get value lists to work on my CWP PHP solution. I have a value list "Test" with four values (one, two, three, four) on a layout called "Test" where I have a field called "Test" that is a drop down menu using the value list "Test". When I use the following code, I get an error on my page. I have two included files one that has the $fm variable created and the filemaker.php include. Here is the code: <?php require_once 'FileMaker.php'; require_once("secure.php"); $layout = $fm->getLayout('Test'); $values = $layout->getValueListTwoFields('Test'); ?> What I want to do is create a drop down list on my web page where the user can select from a predefined list of values. This however is seeming really difficult to do. Does anyone know why I would get an error with this? Thank you, Dan.
doughemi Posted October 24, 2015 Posted October 24, 2015 You need to find out what error is being thrown: $layout = $fm->getLayout('TestLayout'); // ************* // Error Checking Code if(FileMaker::isError($layout)){ echo 'Layout Error: ' . $layout->getMessage() .'<br>'; } // ******************** $values = $layout->getValueListTwoFields('TestVL'); // ************* // Error Checking Code if(FileMaker::isError($values)){ echo 'VL Error: ' . $values->getMessage() .'<br>'; } // ******************* $vl = '<select name="Values">'; foreach ($values as $value) { $vl .='<option value="' . $value . '">' . $value . '</option>'; } $vl .= '</select>'; ?> <html> <head> <title>ValueList Test Page</title> </head> <body> <center> <form action="VLTest.php" name="trial" method="post"> <?php echo $vl; ?> <input name="submit" type="submit" value="SUBMIT" /></form> </td> </body> </html> Note that I changed the names of the layout and value list. Too many entities named "Test" got my head spinning. The messages returned from the two if statements should get you started. Post again if it doesn't get clear for you.
Danjmains Posted October 24, 2015 Author Posted October 24, 2015 (edited) You need to find out what error is being thrown: $layout = $fm->getLayout('TestLayout'); // ************* // Error Checking Code if(FileMaker::isError($layout)){ echo 'Layout Error: ' . $layout->getMessage() .'<br>'; } // ******************** $values = $layout->getValueListTwoFields('TestVL'); // ************* // Error Checking Code if(FileMaker::isError($values)){ echo 'VL Error: ' . $values->getMessage() .'<br>'; } // ******************* $vl = '<select name="Values">'; foreach ($values as $value) { $vl .='<option value="' . $value . '">' . $value . '</option>'; } $vl .= '</select>'; ?> <html> <head> <title>ValueList Test Page</title> </head> <body> <center> <form action="VLTest.php" name="trial" method="post"> <?php echo $vl; ?> <input name="submit" type="submit" value="SUBMIT" /></form> </td> </body> </html> Note that I changed the names of the layout and value list. Too many entities named "Test" got my head spinning. The messages returned from the two if statements should get you started. Post again if it doesn't get clear for you. No work Using the following code (I renamed the value list to TestValueList) I got "The page cannot be displayed because an internal server error has occurred." $layout = $fm->getLayout('Test'); if(FileMaker::isError($layout)) { echo 'Layout Error: ' . $layout->getMessage() . '<br/>'; } $values = $layout->getValueListTwoFields('TestValueList'); if(FileMaker::isError($values)) { echo 'VL Error: ' . $values->getMessage() . '<br/>'; it cut off the last ending } there but yeah the filemaker error capturing doesn't even tell me anything cause it won't process the page. Using the default php install by FMS14 Edited October 24, 2015 by Danjmains
doughemi Posted October 24, 2015 Posted October 24, 2015 Try a simple php file <?php date_default_timezone_set("America/New_York"); ini_set('display_errors', '1'); define('FM_HOST', '<yourHost>'); $fm_file = '<yourFilename>'; $fm_user = 'username' ; $fm_pass = 'password' ; include ('filemaker14/FileMaker.php');// or your path to FileMaker.php # instantiate a new FileMaker object $fm = new FileMaker($fm_file, FM_HOST, $fm_user, $fm_pass); $errorcheck = $fm->listLayouts(); if(FileMaker::isError($errorcheck)){ echo $errorcheck->getCode() . ': ' . $errorcheck->getMessage(); } echo '<pre>'; print_r ($errorcheck); Does the same error occur?
Danjmains Posted October 26, 2015 Author Posted October 26, 2015 Try a simple php file <?php date_default_timezone_set("America/New_York"); ini_set('display_errors', '1'); define('FM_HOST', '<yourHost>'); $fm_file = '<yourFilename>'; $fm_user = 'username' ; $fm_pass = 'password' ; include ('filemaker14/FileMaker.php');// or your path to FileMaker.php # instantiate a new FileMaker object $fm = new FileMaker($fm_file, FM_HOST, $fm_user, $fm_pass); $errorcheck = $fm->listLayouts(); if(FileMaker::isError($errorcheck)){ echo $errorcheck->getCode() . ': ' . $errorcheck->getMessage(); } echo '<pre>'; print_r ($errorcheck); Does the same error occur? No, I've already been using the PHP API to do other things like POST data into my database, etc. it just gets this error anytime I try to use a value list. As soon as I take away the code for the value list it works fine.
doughemi Posted October 26, 2015 Posted October 26, 2015 The code I posted above works fine for me. Server errors have happened to me when a database has not been properly opened in FMS. They would not normally occur as a result of API calls after the database has been opened. My sample is attached. ValueListTest.zip
Danjmains Posted October 26, 2015 Author Posted October 26, 2015 The code I posted above works fine for me. Server errors have happened to me when a database has not been properly opened in FMS. They would not normally occur as a result of API calls after the database has been opened. My sample is attached. ValueListTest.zip Using these files I still got the same error. Uploaded to server via FMP 14 Advanced, used the php and database you attached, no luck.,
doughemi Posted October 26, 2015 Posted October 26, 2015 I am not familiar with checking or setting Windows file permissions (for the database), but that is where I would go next. Hopefully one of the Windows gurus will pick up the ball.
Danjmains Posted October 26, 2015 Author Posted October 26, 2015 I am not familiar with checking or setting Windows file permissions (for the database), but that is where I would go next. Hopefully one of the Windows gurus will pick up the ball. Everything else works fine, I'm able to login, read data, write new data, get portals, perform finds, etc. It only happens when value lists are involved for some reason. It's really weird. This is using the admin account as well.
doughemi Posted October 26, 2015 Posted October 26, 2015 Did you change the PHP API files to the FMS14 versions when you upgraded to 14? I had some weird problems when I didn't do that between 12 and 13. They are in a zip file in Filemaker Server/Web Publishing/ directory.
GManNAtl Posted March 23, 2016 Posted March 23, 2016 If I am not mistaken getValueListTwoFields requires 2 parameters. The fieldname and also the RecordID.
Recommended Posts
This topic is 3167 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