Jump to content

FMP14 CWP Value Lists


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

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Danjmains
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 months later...

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