Questions

Please use this page to post your questions about PHP, FileMaker, AppleScript, or anything else you can think of. I will do my best to answer everything in a timely fashion.

When submitting questions, please be sure to provide your email address - I almost always have to get in touch with people to clarify their question, get sample files, etc. Rest assured that your email WILL NOT be shared in any way.

Email (optional)

Question (tags and code will be displayed as entered)

What is 2 plus 5? (so I know you that are not a spambot)

Please send me occasional email announcements


Question 1
Why should one use the containerbrige.php / img.php from the API-examples ($fm->getcontainerdata) to show the contents of a container field? I was using

echo "<img src=".$record->getField($fieldName)." />";

and it works and it seems much simpler.
Answer
The src attribute of the img tag creates a new request to the server. If you have a page with 25 images on it, the server gets hit 26 times -- once for the page content itself and once each for the 25 images.

The initial page request is getting filtered through FileMaker.php before going to the server. This allows you to do all sorts of preprocessing, including specifying a username and password to connect to the database. The raw URL inserted into the src attribute of the img tag does not benefit from this preprocessing. It’s just a raw URL, and it’s requesting a database connection, so naturally, the database wants to know who’s knocking -- therefore, if there is a password for the database, the img tag will prompt you for a password.

You could embed the username and password in the img src attribute, like so:

echo '<img src=http://esmith:m4rg0t@127.0.0.1'.$record->getField('Thumbnail').'" />';

...but that would be revealing your login information to the whole wide world.

Do NOT do that.

All a user would have to do is view the source on your page to get the login credentials for the database. You could also allow guest access to the file so that the data could be accessed with no login at all.

Don't do that, either.

This is where the containerbrige.php / img.php from the API-examples comes in. The solution is to point the src attribute at another PHP page. Naturally, you can pass information to this page just like any other, so you send the image path to it. Then, the page can preprocess the connection, handle the database login, get the actual contents of the container field, and return the picture to the browser. Voila! All of your login information is safely hidden.

When the main page loads in the user's browser, the image tag (or tags) calls the img.php page. Here is the new img tag:

echo '<img src="img.php?path='.urlencode($record->getField('Thumbnail')).'" />';

As you can see from the code, what I’m doing is passing the path to the image to the img.php page in the path variable. Notice that I'm using the PHP function urlencode() to pass the URL. This is important because if you don't do it, the browser will be hopelessly confused between what is the real URL, and what is data in the query string.
Question 2
I'm presently using $fm->getcontainerdata to display .pdf files, but it is causing all kind of display problems with acrobat reader 6 and 8 (7 works fine...). I'm not sure if the problem comes from the getcontainerdata method or from a $_GET that is over 45 caracters. As unchecking the "display in browser" option of acrobat doesn't solve anything, I'm trying to create a temp .pdf file on the server and use a Javascript redirection. Is there a way with php to extract the data from a container field into a file, or would I need a script from the database?
Answer
The issue here is that you need to give the browser hints about how to handle the contents of the container field. In most cases, browsers will just display the binary text in the browser window, which looks like a huge chunk of garbage. What you need to do is use the PHP header() function to tell the browser that the data that you are sending is not to be treated as plain text. Here is an example that handles a few different file types:

<?php

if ( empty($_GET['-url']) ) {
    die('Missing URL information.');
} else {
    $url = $_GET['-url'];
}

// Include the API files
require_once 'FileMaker.php';
require_once 'error.php';

// Create a FM connection object
$fm = new FileMaker($DBName, $DBHost, $DBUser, $DBPass);

// Set the guts of the file into the $file var
$file = $fm->getContainerData($url);

// Grab the last 3 characters in the url, which should be the file extension
$type = strtolower(substr($url, -3));

// Output the headers needed for the type in question
if ( $type == 'pdf' ) {
    header("Content-Type: application/pdf");
    
    // this line should set the default file name in the save dialog to downloaded.pdf
    header('Content-Disposition: attachment; filename="downloaded.pdf"'); 
    
} elseif ( $type == 'mov' ) {
    header("Content-Type: video/quicktime");
    
} else {
    header("Content-Type: image/jpg");
    
}

// Send the content length header
header("Content-Length: " . filesize($file));

// Output the guts of the file to the browser
echo $file;

// Halt execution (in case there is more php in the calling page)
exit;

?>

There is some good information on this topic that can be found here on the PHP website and also here in an FAQ for the fpdf library. Note that you don't need to use the fpdf library to handle container field contents. Their FAQ just happens to address the browser behavior in question.
Question 3
I (and my users) like to use the mouse as little as possible and rather use the keyboard for input.

When using a regular FileMaker Pro client in Find mode, pressing the Return key (or Enter on the numeric keypad) will execute the Find with the given find criteria.

Using a Web client however, pressing Return or Enter will insert a newline into the field where the cursor is.
Is there any way to prevent this and make Return/Enter perform the find?
(I have only tried this with IWP)

Thanks,

Daniel SjÃstrand
Answer
Some quick testing on my end indicates that the IWP rendering engine converts all FileMaker fields to HTML textareas, as opposed to normal HTML text inputs. Pressing the return or enter keys in a textarea inserts a carriage return. This is unlike text inputs, which do not accept carriage returns. As you know, pressing the enter key with your cursor in a normal HTML text input submits the form (actually, this depends on the order of the buttons and the browser implementation, but normally it would submit the form).

That FMI picked textareas over text inputs makes sense in because FMP fields accept carriage returns, so it would be impossible to use text inputs in IWP. I admit that it would be nice if a Find in IWP could be executed by pressing the enter key, but I think this is just a side effect of the inherent differences between FMP and a browser based application.
Question 4
In FMP, I've created a valuelist ['districts_vlist'] and set up a field ['districts_interested'] to display that valuelist as checkboxes.

I ran the PHP Site Assistant, and it created a series of pages.

While addrecord.php and editrecord.php display the empty checkboxes and value list items correctly, if the user checks 2 or more boxes, only the value checked last in the series is passed back to the database file when submitted.

And browserecord.php is set up to display just the text of only the checked value list items. I want to display the entire series as checkboxes, both checked and unchecked items, in the browse view as well.

In fmview.php, the following code is generated:

function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) {
    $selected = "";
    foreach ($valuelist as $eachvalue) {
        if ($eachvalue == $fieldvalue)
            $selected = " checked";
        else
            $selected = "";

        echo "<input type='$type'name='$fieldName'value='$eachvalue'$selected>$eachvalue";
    }
}

and then the code to display the checkboxes in editrecord.php is:

getInputChoices("checkbox", $layout->getValueList('districts_vlist', $record->getRecordId()), $record->getField('districts_interested', 0) , getFieldFormName('districts_interested', 0, $record));

Can you see what code is missing to permit more than one checkbox to be checked and reported back to the database? And likewise to view more than one checked box in the webpage?

...or...

Based on the article you wrote:

http://filemaker.com/downloads/pdf/pr_php_part2.pdf

I came up with this work-around code and was able to at least get multiply-checked checkboxes to display correctly in browserecord.php [in place of using the getInputChoices function]:

$fieldName = getFieldFormName('districts_interested', 0, $record);
$fieldValue = $record->getField('districts_interested');
$values = $layout->getValueList('districts_vlist');
foreach($values as $value) {
    $checked = (strpos($fieldValue, $value) !== FALSE) ? ' checked="checked"' : '';
    echo "<input type=\"checkbox\" name=\"{$fieldName}[]\" value=\"{$value}\"{$checked} />{$value}<br />\n";
}

...BUT if I try to use that same code in the editrecord.php page as well, it's kicking back these 2 error messages:

Notice: Array to string conversion in .../fmview.php on line 386

Warning: urlencode() expects parameter 1 to be string, array given in .../FileMakerImpl.php on line 327

So how do I now send the data back to FMP via editrecord.php in a format that the PHP Site Assistant generated pages will accept?

Thanks.

jeff rouse
Answer
Apparently, the PHP Site Assistant code is not set up to handle an incoming array, which is what is created when a series of checkboxes is checked. I have not had time to dig into the generated code to come up with a patch. Plus, I am hoping that FMI just fixes this anyway.

In the meantime -- and assuming the value list in question is not dynamic -- you could break out each value list option as it's own field and display as a radio button with True or False values. Then, you could change your original checkbox field to a calc that referenced the new fields. I know that sucks, but it's all I've got for now.
Question 5
I am using php site assistant. I have a nice site based on a fm db that is basically a to do list. I have a field called done which is selected from a value list: done, in progress, not started, waiting. First of all the neq on the find page does not work if i am trying to see everything not 'done'. I need to use the greater than 'done' to see everything not done. Second, how can i set a default to find records that are not done without using the find page which some people find cumbersome?
Answer
I have not yet had a chance to test your issue with the neq not working, however I can point you in the right direction with the "default find request" question. You should be able to add a "findnotdone" action to the switch statement in the recordlist.php to look something like this (new lines are highlighted):


switch ($action) {
case "findnotdone": {
// clear the recid
$cgi->clear('recid');
// create a find not done command
$findCom = $fm->newFindCommand($layoutName);
$findCom->addFindCriterion('Status', 'Done');
$findCom->setLogicalOperator('-neq');
ExitOnError($findCom);
}

case "findall": {
$cgi->clear('skip');
$findCom = & $fm->newFindAllCommand($layoutName);
break;
}
case "find": {
// clear the recid
$cgi->clear('recid');
// create a find command
$findCommand = $fm->newFindCommand($layoutName);
ExitOnError($findCommand);
// get the posted record data from the findrecords page
$findrequestdata = $cgi->get('storedfindrequest');
if (isset($findrequestdata)) {
$findCom = prepareFindRequest($findrequestdata, $findCommand, $cgi);
// set the logical operator
$logicalOperator = $cgi->get('-lop');
if (isset($logicalOperator)) {
$findCom->setLogicalOperator($logicalOperator);
}
} else
$findCom = $fm->newFindAllCommand($layoutName);
break;
}
default: {
$findCom = & $fm->newFindAllCommand($layoutName);
break;
}
}

Once you have that set up, you will want to display the following code somewhere for your users to click to call the new switch block:

<form action="recordlist.php" method="post">
<input type="hidden" name="action" value="findnotdone" />
<input type="submit" value="Find Not Done" />
</form>

Be warned, I am just typing this code up from memory - I didn't test it at all, so you might have some debugging ahead of you. Please LMK how it goes.
Question 6
I have a value list that contains approximately 100 values. The first field is numeric and links to a field in my table. It has no meaing to my users. The second field is descriptive and gives the users information that has meaning to them. Both fields are pulled from a lookup table. I can't figure out how to use getValueList() (assuming that's the method I should be using) to show the second field in my array. I have two pieces of code that generates the number. The first was created by Filemaker when I created my PHP code by using PHP Site Assistant.

<?php
getMenu(
    $layout->getValueList('Projects', $record->getRecordId()),
    $record->getField('Proj_Code_fk', 0),
    'Project',
    getFieldFormName('Proj_Code_fk', 0, $record)
);
?>

Proj_Code_fk is in my primary table and links to Code in my Value List. The code I'm posting below is what I created, but still only shows the first field.

<?php 
$valuesArray = $layout->getValueList('Projects', $record->getRecordId());
foreach($valuesArray as $field_object) {
    $field_names = $field_object->getName();
    print ($field_names);
}
?>


Answer
I did some quick investigating and my initial conclusion is that you are going to have to "roll your own" value list in the PHP code by sending an additional query to the database to pull the information that you need for both sides of the value list. Just do find against the table that the value list is based on and loop through the records to build your value list. I know that this is a drag, but I don't see another option.
Question 7
hello,
sorry-i posted to the contact page-please ignore.

You fm to ical is awesome!!!
I am in the process of designing a little database linking fm to ical, using your example.
I would like to include the "attendees" in the export but cannot figure out how to get the field to show up in ical. I tried to modify your applescript with no success. Any help would be greatly appreciated.


tell theEvent
set start date to theStartDate
set end date to theEndDate
set summary to theSummary
set description to theDescription
set attendees to theAttendees
end tell



Not sure what I am missing here.

Thanks

Joe
Answer
Your trouble is that Attendees are not a property of an Event - it is a child of an Event. If you have more than one attendee in your filemaker field, you will need to loop through the list of names and add each on individually to the event. If you only have one, this code snippet should do the trick:

tell theEvent
set start date to theStartDate
set end date to theEndDate
set summary to theSummary
set description to theDescription
set attendees to theAttendees
make new attendee at beginning of attendees with properties {display name:theAttendeeName, email:theAttendeeEmail}
end tell

Question 8
Just generated a test search site using php site assistant, and the file fmview.php requires a file named "Date.php" that does not exist, anywhere. It's not in the API, and it's not among the new files generated by site assistant. Where is this file to be found? Site does not work without it, even commenting out the require statement doesn't do it. Thanks.
Answer
I have heard about this from a few other people, although I have not experienced it myself. Some other folks have had success with commenting out the line, so I do not know why that has not worked in your case. It could be that you are not using PHP5, which I believe is required for the code generated by the PHP Site Assistant. Also, the FileMaker API for PHP uses cURL functions, so you should check your PHP installation to make that is was complied with cURL support.

UPDATE: I finally had some time to really look into this and yes, sites generated with the PHP Site Assistant definitely require PHP5. For example, fmview.php uses the PHP5-style constructors. I am sure there are other issues as well, but that one jumped out at me. Also, the Date.php file is in fact a PEAR file that is included when you install the FMS9 version of PHP, which unfortunately you didn't/couldn't do.

I guess the bottom line is that FMI is expecting you to install the FMS version of PHP if you are going to use the PHP Site Assistant. I scoured the docs that ship with FMS9 and if there is any mention of the PHP 5 requirement for PHP Site Assistant sites, I couldn't find it. Sorry not to be of more help.
Question 9
I have created several databases with the PHP FileMaker Site Assistant. When I do a find request and leave my search fields blank, it does a find all search and displays all records. What I want it to do, and what it did in FileMaker 4, was to say no results found. From looking at the code the findrecords.php page is set to just do a find and not find all.

Basically, I created a database and used the PHP site assistant. I have fields "a" and "b". I want people to fill in at least one of those fields to find a record. I removed the "find all" feature from the site as I want people to put a search term. (The people using the database know what to search for).

In Filemaker 4, using the Clairis site assistant to make a site, if I did a search leaving a and b blank I would get no records found. Which is what I want. In 9, leaving "a" and "b" blank and doing a search I get all the records.

An example would be customer number and order number. I want customers to search for their orders and not be able to see everyone else's order.

Thanks!
Answer
If you really don't want your customers seeing each other's data, you should probably modify the whole site to pull their customer id at login, store it in the session, and then include it with any subsequent find request to prevent curious customers from successfully guessing someone else's customer id. Of course, doing so is a fair amount of work and you don't seem to be worried about it anyway ;)

I think you are going to have to poke around in the PHP code and add some of your own to make this work the way you want. Fortunately, since you removed the "find all" feature, it sounds like you are at least somewhat comfortable doing that sort of thing.

I think your trouble is in this section of the recordlist.php page:

// get the posted record data from the findrecords page
$findrequestdata = $cgi->get('storedfindrequest');
if (isset($findrequestdata)) {
$findCom = prepareFindRequest($findrequestdata, $findCommand, $cgi);
// set the logical operator
$logicalOperator = $cgi->get('-lop');
if (isset($logicalOperator)) {
$findCom->setLogicalOperator($logicalOperator);
}
} else {
$findCom = $fm->newFindAllCommand($layoutName);
}

This is a messy fix, but you could do this instead:

// get the posted record data from the findrecords page
$findrequestdata = $cgi->get('storedfindrequest');
if (isset($findrequestdata)) {
$findCom = prepareFindRequest($findrequestdata, $findCommand, $cgi);
// set the logical operator
$logicalOperator = $cgi->get('-lop');
if (isset($logicalOperator)) {
$findCom->setLogicalOperator($logicalOperator);
}
} else {
die ('You have to specify some search criteria. Please you your browsers back button to try again.');
}


Please LMK what you end up with.
Question 10
I recently bought a copy of your book on PHP and FM9. I must said it was very well written. However, there is something that I wanted to know but I could not find it in the book.

My Filemaker database has users access login name and password. Each user is only allow to view certain portion of the database , depending on his or her Access Rights and Privileges. When I publish my database in PHP (Intranet), I want to have the same security access for the users. How do I do that in PHP ?

Thank you very much
Leong (Singapore)
Answer
Great question. I my book, all the examples use a single hard-coded set of access credentials. This is convenient in many cases, because access to the database is already significantly limited just by virtue of the fact that users have to access it through your web interface. However, as you point out, it is sometime preferable to repurpose your work in the Accounts & Privileges dialog to the web as an added layer of security.

What you need to do is set up a PHP login routine that prompts the user to provide login credentials. You then store the provided username and password in the $_SESSION array. Once you have the credentials stored, you use those in place of the hardcoded ones whenever a user needs to connect to the database.

Overall, this sounds like a great idea. However, it does mean that you are going to have to add a lot of error checking to your PHP pages, because in any given situation you won't know if the user really has permission to do what they are trying to do. This is not a bad thing, but you need to be aware of it.

I am planning to do an article on this in an upcoming issue of FileMaker Advisor, but in the meantime you can use the PHP Site assistant to generate a site that does not hard-code the login credentials. Once you generate the pages, just dig around in the login routine to see what's going on.
Question 11
[I posted this to the FileMaker TechTalk list, but got no replies...]

I have an edit page created with the PHP Site Assistant. All of my
FileMaker two field value lists to not work automatically on the web--
they only show the id or code, not the meaningful value text. I have
done some reading and understand I have to manually build the
option/value pairs to generate the list from the related table. It seems
like I have done this part, but do not know how to get the current
record's field value to display, or get the value selected (and
submitted) to be recorded.

In my database, an inventory item's 'Location_bldg_id' is related to
BUILDING via 'BLDG_NO'. In the database, I have created a two field
value list called Buildings which displays/records the
Location_bldg_id/BLDG_NO value, but displays the BLDG_NAME.

On the web I need to display a similar value list of buildings while
recording the BLDG_NO selected as the Location_bldg_id for the edited
record.

From the edit item php page, the original Site Assistant code:

<td class="field_data">
<select name="<?php echo getFieldFormName('Location_bldg_id', 0,
$record);?>">
<option value="">
Location_bldg_id
</option>
<?php getMenu($layout->getValueList('Buildings',
$record->getRecordId()), $record->getField('Location_bldg_id', 0) ,
'Location_bldg_id', getFieldFormName('Location_bldg_id', 0, $record));?>
</select>
</td>

This displays a value list of the BLDG_NOs from the database's Building
value list (001, 002, 003...), with the current field data the selected
item of the list (005).

I know next to nothing about PHP, so I am pretty excited that I've
gotten the list with building numbers and names to draw at all! My
custom value list displays all the buildings with the correct numbers
and names (<option value="001">Eddy Hall</option>...), but I cannot get
the current record's Location_bldg_id to be the selected item in the
value list (<option value="005" selected>Nicholson Hall</option>), nor
get the new selected value recorded when the record is submitted. Here's
my value list:

<td class="field_data">
<?php
$request = $fm->newFindAllCommand('BUILDING');
$result = $request->execute();
$records = $result->getRecords();
$values = '';
foreach ($records as $record){
$values .='<option
value="'.$record->getField('BLDG_NO').'">'.$record->getField('BLDG_NAME').'</option>';}
?>
<select name="Location_bldg_id">
<?php echo $values; ?>
</select>
</td>

Can you tell me what I need to do to modify my new value list to
work properly?

Thanks much,

Elleni
Answer
Hi E -

Working with HTML Select inputs is a real pain in the arse, and I am afraid you are going to have to totally roll-your-own to get what you want. For now, read up on how they work here:

http://www.w3schools.com/tags/tag_select.asp

In particular, give the "Try-It-Yourself" demos a look.

If I can find the time, I am going to write an article on working with select lists and will let you know when it is ready. I am afraid it's a bit of an involved answer.

Thanks,
j
Question 12
Hey Jonathan-

I've entered example 06 01 (pg 95) from the book and when I run the script I get:

Fatal error: Call to undefined method FileMaker_Error::getRecords() in /Library/WebServer/Documents/testB.php on line 13

Pages generated with the PHPSA all work fine, so I know the server is configured OK. The inlcude is definitely working, and I've tried this page with several different test databases and get the same results with each one. I know you said that your writing was based mostly on the API Beta...is it possible that the code wouldn't work with FMSA9?

NR


<?php
define ( 'FM_HOST', '192.168.1.2' );
define ( 'FM_FILE', 'CompanyDB' );
define ( 'FM_USER', 'esmith' );
define ( 'FM_PASS', 'm4rg0t' );
include ( 'Filemaker.php' );
$fm = new Filemaker (FM_FILE, FM_HOST, FM_USER, FM_PASS);
$request = $fm->newFindAllCommand('Company List');
$result = $request->execute();
$records = $result->getRecords();
$rows='';
foreach ($records as $record) {
$rows .= '<tr>';
$rows .= '<td>'.$record->getField('Company').'</td>';
$rows .= '<td>'.$record->getField('Address').'</td>';
$rows .= '<td>'.$record->getField('State').'</td>';
$rows .= '</tr>';
}
?>
<html>
<head>
<title>06_01</title>
</head>
<body>
<table border = "1">
<tr>
<th> Company </th>
<th> Address </th>
<th> State </th>
</tr>
<?php echo $rows; ?>
</table>
</body>
</html>
Answer
This is a classic situation - I get this question a lot. When you execute this line...

$result = $request->execute();

...you are getting an Error object back instead of the Result object that you were expecting. So, when you run this line...

$records = $result->getRecords();

...you are getting a fatal error because the Error object contained in the $result variable does not have a method called getRecords(). The error could be anything, but if it were me I would check my user/pass credentials first. Next, I would make sure the the PHP extended privilege is enabled for the account in question.

What you need to do is refer to the error checking appendix in the book and add in some error checking code to determine why your request is returning an error instead of a result. In a nutshell, you are going to want to add a code block like this after the execute line:

if (FileMaker::isError($result)) {
die('<p>' . $result->getMessage() . ' (error ' . $result->code . ')</p>');
}

You may have noticed the HaltOnError function that is used in the pages generated by the PHP Site Assistant. Delving into that function might be educational as well.

HTH,
j
Question 13
Two things:

1. We are going to try to produce a website with FileMaker to accept applications. It will need to be secure and allow individuals to enter data until they are complete and then lock them out.

2. I am using your custom function WordWrap and would like to maintain any existing carriage returns. Sometimes the existing return is required and I would like it to remain.

Can you help?

Thanks, Mike
Question 14
Hi Jonathan Stark,

is there a possibility to get the result of a FileMaker-Script:

$newPerformScript =& $fm->newPerformScriptCommand('test', 'checkdata', '1234');
$result = $newPerformScript->execute();

The result is returned with the parameter of the FileMaker 'exit spript' command.

Kind regards

Uwe Holzer
Answer
Hi Uwe -

Great question. I get asked this one a lot, probably because it would be a very convenient feature to have. Alas, there is nothing built-in to the FileMaker API for PHP to do this for you. However, you can approximate the desired behavior by taking advantage of the default behavior of running FileMaker scripts via PHP.

When a running a FileMaker script via the web, FileMaker returns the data from the found set of the layout that the script is on when it completes. This is very useful if you are running scripts that need to return found sets, but as you found, not always what you want. What you can do is tack a few lines onto the end of your script that basically do the following:

1) Store the desired result in a script variable.
2) Go to a layout based on a dummy table with a single field on it.
3) Omit all records.
4) Create a new dummy record.
5) Set the single field to the contents of the script variable.

This arrangement will deliver a result to your PHP code that contains a found set of one record and one field. You can then use normal result methods like getRecords() and getField() to pull your script result.

HTH,
j
Question 15
Any pointers on how to get iCal data into FMP 9?

Thanks.
Answer
I have not done exhaustive testing, but I have not noticed any difference between FMP8 and FMP9 with regard to iCal and AppleScript. Check the downloads page - there are several examples.
Question 16
I know a similar question was posted (Q6) earlier, but looking for exact detail on how to do...

Many of my filemaker value lists have an id# and a descriptive name. Ex: Firm id is the value from the first field and firm name is the value from the 2nd field.

When Outputting my checkboxes or radio buttons to web with php I want to be able to get the value list items as php array(s), then....:

echo "
<label for = '(1st firm name here)'>
<input type = 'radio' name = 'firmchoices' value = '( 1st firm id# here)'/>(1st firm name here)
</label>"

php script loops thru an array of all the firm id#s and matching firm name pairs in my value list spitting out radio buttons for each firm...
How can I get that to work exactly? Thanks for any help. Much appreciated.
Answer
Hi M -

The long and the short of it is that for compound value lists, you need to forget about trying to pull the data for the HTML from the value list itself. Instead, you want to directly query the table that the value list is based on and use that as your source data for the form.

Make sense?
Question 17
Good Day Sir,

I created a simple Satisfaction Survey and used the PHP Site Assistant to created Add New Record Site.

This worked fine until I moved the site to a new Web Server running the FileMaker Web Publishing Engine connected to a Server running FMSA 9.02. I edited the phpsa file to indicate the new IP address of the Web Server.

When I create a new record everything appears fine including a confirmation message after "Saving Record".

When I login to the database visa the network the new record is not in the database.

I must be missing an edit somewhere and would appreciate your suggestions.

Thanks in Advance

greg
Answer
Thanks for your question. There are about a million things that could be causing your problem... Can you tell me more about the hardware and network configuration involved? It might help to know exactly what you have installed where, and how the various machines are networked together. I'm guessing that since the site was working prior to the move, you are having a communication issue.
Question 18
My question is regarding files produced by FM PHP Site Assistant (FMServer 9). If the search field/s in the Search Page (findrecoreds.php) is empty, the program defaults to "Find All" and displays all records in the database. How do I configure the search command so that a blank field is a search criterion?

Thanks,

Yoshi

Answer
Hi Yoshi -

Thank you for your inquiry. In answer to your question, you are going to want to prepend double equals signs to the values provided by the user in the login form.

So, if the user enters:

Username: esmith
Password: m4rg0t

The action page will do something like this prior to sending the request to FileMaker:

$_username = '==' . $_POST['username'];
$_password = '==' . $_POST['password'];

I am oversimplifying a bit for the sake of clarity, but that's the FileMaker portion of the concept. As with any form submission, you would also want to check the POST array for malicious data, etc...

HTH,
j
Question 19
Dear Jonathan,

everytime I use the newPerformScriptCommand I get a error:

Notice: Only variable references should be returned by reference in C:\Programme\FileMaker\FileMaker Server\Web Publishing\publishing-engine\php\FileMaker\Command.php on line 126

.....
$newPerformScript =& $fm->newPerformScriptCommand('layout', 'script', $parameter);
$result = $newPerformScript->execute();
...

The script works fine

Kind regards

Uwe

UPDATE:

I found a solution in the FM technet.

That seems to be an issue with some depreciated PHP syntax used within the FileMaker internals (with incorrect assignment operators). However to avoid the issue in your case, add the error silencing "@" for the execute operation...


Answer
Cool! Glad to know technet is helping someone.
Question 20
there is just one little problem, thank you very much for your help but i still have a problem please do help me, now my problem is after i click next it will not show records. i change the $max = 1. because i want to display one per page, can u help me to do this... so if there were 10 records the user will click 10 times on the next button. here is my code:


This is the link or the button:
<p class="recordlist_nav" style="text-align: center">
<span class="recordlist_nav_first"><?php echo $statusLinks['first'] ?></span>
<span class="recordlist_nav_prev"><?php echo $statusLinks['prev'] ?></span>
<span class="recordlist_nav_range">Records <?php echo $statusLinks['records']['rangestart'] ?> - <?php echo $statusLinks['records']['rangeend'] ?> of <?php echo $statusLinks['records']['foundcount'] ?></span>
<span class="recordlist_nav_next"><?php echo $statusLinks['next'] ?></span>
<span class="recordlist_nav_last"><?php echo $statusLinks['last'] ?></span>
</p>
Now the functions:

<?php
$juan = isset($_GET['john']) ? $_GET['john'] : '';
$famdat = isset($_GET['fam']) ? $_GET['fam'] : '';
$skp = isset($_GET['skp']) ? $_GET['skp'] : 0;

//$skp = 0;
$resultdat = 0;
$max = 1;
require_once 'classes/FileMaker/FileMaker.php';
$_FMP_CONN = new FileMaker();
$_FMP_CONN->setProperty('database', 'Conch Philcoll V3');
$_FMP_CONN->setProperty('hostspec', 'http://192.168.130.164');
$_FMP_CONN->setProperty('username', 'php');
$_FMP_CONN->setProperty('password', 'php');

$_FMP_FIND = $_FMP_CONN->newFindCommand('WEB');

$fixnum = $juan; //isset($_REQUEST['']) ? $_REQUEST['fam'] : '';


$_FMP_FIND->addFindCriterion('Fix Number', $fixnum);
$_FMP_FIND->addFindCriterion('FAMILY', $famdat);

$lop = isset($_REQUEST['lop']) ? $_REQUEST['lop'] : 'and';


$_FMP_FIND->setLogicalOperator($lop);


$_FMP_FIND->setRange($skp, $max);
$_FMP_FIND->addSortRule('Fix Number', 1, FILEMAKER_SORT_ASCEND);
$_FMP_COUT = clone($_FMP_FIND);

$_FMP_RSLT = $_FMP_FIND->execute();

//GET THE RECORD
$records = $_FMP_RSLT->getRecords();

//var_dump($j);
function generateURLImage($juan) {
return 'http://192.168.130.1/images/PhilippineCollection/web/' . $juan . '.jpg';
}
//for the navigation
function getStatusLinks($ur, $rs, $skp, $max) {
$links = array (
'first' => 'First',
'prev' => 'Prev',
'records' => array (
'rangestart' => 0,
'rangeend' => 0,
'foundcount' => 0
),
'next' => 'Next',
'last' => 'Last'
);
$fetchcount = $rs->getFetchCount();
$foundcount = $rs->getFoundSetCount();
$total = $rs->getTableRecordCount();

if ($total == 0 || $fetchcount == 0) {
return $links;
} else {
if ($fetchcount > 0) {
if ($skp > 0) {
$links['first'] = '<a href="' . $ur. '&amp;skp=0">First</a>';
if ($skp > $max) {
$prevskip = $skp - $max;
$links['prev'] = '<a href="' . $ur. '&amp;skp=' . $prevskip . '">Prev</a>';
}
}
if ($foundcount - $skp > $max) {
$nextskip = $skp + $max;
$links['next'] = '<a href="' . $ur. '&amp;skp=' . $nextskip . '">Next</a>';
$lastskip = $foundcount - $max;
$links['last'] = '<a href="' . $ur. '&amp;skp=' . $lastskip . '">Last</a>';
}
$links['records']['rangestart'] = max($skp, 1);
$links['records']['rangeend'] = min($foundcount + $skp, $fetchcount + $skp);
$links['records']['foundcount'] = $foundcount;
}
}
return $links;
}
//$ur = 'details.php?fam=' . $famdat . '&amp;spc=' . $spcdat . '&amp;qty=' . $qtydat . '';
$ur = 'details.php?fam=' . $famdat . '&amp;spc=' . $spcdat . '&amp;john='.'';
$statusLinks = getStatusLinks($ur, $_FMP_RSLT, $skp, $resultdat);


please i really need your help....
Question 21
Hello Jonathan,

I gone thru some of your books and purchased one last, and everything seems to be very useful.

I have one question,

How can I check a record is present in filemaker table via php? since in mysql, we can check via select query and I don't how to check the same in filemaker-PHP

Can you please help me ASAP -- my mail is mhari@angleritech.com

Thanks in advance.
Question 22
I've just started working with the PHP Filemaker API and have a really basic question. The documentation and examples all say that I need to include require_once('filemaker.php') in my php code yet the code that was generated by the php assistant only has require_once('fmview.php').

What am I missing?

Thanks.
Answer
Hi there,

Technically, the only pages that must include (aka require) FileMaker.php are pages that need to connect to FileMaker. There are files that the PHPSA creates that do not need to talk to FileMaker, and therefore do not need to include FileMaker.php.

HTH,
j
Question 23
Hi Jonathan,

I'm new to PHP for Filemaker 9.0. I used to put javascript to check for missing fields in my forms, but with PHP naming the fields: "<?php echo getFieldFormName('NameFirst', 0, $record);?>" This doesn't seem to work in Javascript anymore.

-Thanks,
Richard
Answer

Hi Richard,

I think the trouble is that the PHPSA getFieldFormName function returns the index number of the field name, not the actual field name. So, you'll need to load the page in a browser, view the HTML source of the page, see what the index number is for the field in question, and then point your JavaScript at the number instead of the name.

HTH,
j
Question 24
Hello Jonathan,

I really very happy to see your mail and help on sorting out the PHP-filemaker API issues.

I need one guidance from you, I have created a small PHP application based on the book written by you and I found the below error when executing the sample exercise, can you please help me ?

Error:
Call to undefined method FileMaker_Error::getrecords()

Thanks in advance..

Regards,
Hari
Answer
Hi Hari -

Please refer to quesiton 12 above for an explanation.

Thanks,
j
Question 25
Hello,
When I am trying to build a site through the PHP assistant with a file that has password protection, the PHP assistant will not connect to that file. The file does show up in the list after connecting to the webserver but when I subsequently supply the correct accountname and password (they do work with 'open remote'..) the PHP assistent returns the message that my login is invalid. Any idea what might be causing this? Win2003server, FMserver9v2.
Thanks,
Sander
Answer
Hi Sander -

Thanks for your question. My first thought is to make sure the the fmphp extended privilege has been assigned to the privilege set that the web user account is associated with. If that's not it, please let me know.

Thanks,
j

UPDATE:
==========================================
Sander wrote:
------------------------------------------
Thank you for taking time to reply. The extended privilige was assigned. The problem turned out to be a security setting on IIS...

In Properties of the Default Website: Directory security
->Authentication and access control -> 'Integrated Windows Authentication' should be OFF. Since anonymous access was already enabled I didn't expect this to be a problem. Apparently it is.

==========================================
Jonathan wrote:
------------------------------------------
Ugh, I should have though of that. That bit me once a while back, but I so rarely use IIS that I forgot. Thanks for the update - I will post your solution on the site in hopes of helping other folks.
Question 26
Jonathan,

I have a question I can't find the answer to. I was looking at using your script FMPtoiCAL to be able to add events to my ical but the ical is running on my server in my office on a static ip and tiger server.

I changed this line in your script to read:

tell application "iCal" of machine "my.ip.address.here"

when I first tried to close the applescript window in FMP script editor, the computer sat for a while then can back with an error saying it could not connect.

after some research I opened port 3031 on my server and had better luck. FMP seemed to try and talk with the server. I was asked my name and password and then after a few seconds I get the error "remote access isn't allowed". This is an error in a FMP window.

Do you know if this is saying my FMP can not do the remote acces or is this a message that FMP received from tiger server and is relaying to me?

I have gone to my server and turned on Apple Remote Desktop and Remote Apple Events in my sharing and I tried turning off my fire wall completly with the same error as a result.

any ideas?

thank you so much for your time and your amazing software,

David
www.audioperception.com
Answer
Hi David -

I am afraid that I do not have any experience with Tiger server. If you end up figuring it out, please let me know and I will post your solution for others.

Thanks,
j
Question 27
I have perhaps the most basic question but I can't seem to find the correct search term to clarify any results as I google it.

I have read the book but perhaps I have passed over the answer or have spent to much time with MySQL.

I built a database of Art that I have built and published using the PHP SA. I defined fields for Artists, Size, Colors, Available, Sold etc.

I have a standard PHP page with the artists names and bios. I would like to create a simple link that goes to recordlist.php and shows all of that particular artists work that is currently available.

Namely can I modify this URL to give me just one artists work that is currently available, having artists and available as two fields in my database.

recordlist.php?-skip=0&-db=SOTA&-max=10&-lay=Form%20View&

Or do I always have to do a form that executes a search or is the url enough of a command for filemaker like on the findrecords.php page.

Thanks,
Matt
Question 28
Hi,
I have a small site (contacts) generated with php site assistant.
Let's say in the record list page I have the first 25 records of a found set.
I have the option to sort them let's say by Last name by clicking on the underlined column header.
Everything works as expected, but when I click on Next (25 records) the sort order is lost and contacts are again presented in an order that is not by Last name...
What gives?
Question 29
Meixfy <a href="http://jzycrfhjulvh.com/">jzycrfhjulvh</a>, [url=http://ubigixikztpx.com/]ubigixikztpx[/url], [link=http://qyzgiepbkimt.com/]qyzgiepbkimt[/link], http://auurznusvmog.com/
Question 30
I love your example of using FileMaker as a content management system for our website. I'm not the greatest at PHP and am getting stuck on how to develop a secondary navigation menu under the main menu. Do you have any other resources on this topic?

Jon
Question 31
Hi Jonathan,

Iam working in lot of php & filemaker integrated projects now. I have a problem in a client PHP server, and the issue is -- I can able to login to PHP assistant in the client server, but when I am doing step by step to create PHP files -- when I reached the layout group, I could not able to see any tables or layout in the white box under the text layout group..

Can you please help me ?

Hari
Question 32
A quick question...

Is it possible to check if a field in a filemaker layout is editable in browse mode from PHP?
($field->isAutoEnter() or $field->getType() are not enough)

In other words... if I want to display not editable data in an "edit record" form in my website, do I have to manually define which fields are editable or can I get some info from the layout?

Thanks in advance!

Question 33
I have just about got my Filemaker PHP site done. All I need to do is add a link that will find all the records where Field "CG ' equals "D". I can see that the PHP publisher by FM, produced this link for find all:

http://192.168.26.13/search/recordlist.php?-db=usna61&-sortorderone=ascend&-max=25&-sortordertwo=ascend&-lay=Web&-action=findall&-sortfieldtwo=First%20Name&-skip=0&-sortfieldone=Last%20Name&

Is there a way to create a similar link that will find all the records where the field "CG" contains "D"? Thanks, for any advise.
Question 34
I'm trying to use getRepetitionCount() to get me the number of repetitions for a field in my layout but I can't figure out how to get it to work. I need a loop to do stuff with all the repetitions but I can't get the repetition count.

What's the right way to do that?

Thanks
Answer
I suspect that your trouble stems from FileMaker's inherently confusing terminology regarding fields. The word "field" is used to describe two very different things: a field in a table, and a field on a layout. In most other places, these to things are described as a "column" and a "cell". When I teach Intro to FileMaker, I take great pains to distinguish between a "table field" and a "layout field" because people inevitably get hung up on it.

To make matters worse, the PHP API compounds this ambiguity offering methods of different objects named getField() or getFields(). Each method returns very different things depending on what object it is being called from. But I digress...

I have not seen your code, but I am willing to bet you are calling the getRepetitionCount() method without having a valid field object. Substitute your info into the code below and let me know if it works for you.


<?php
# For security reasons, these lines should be
# included from a file above the web directory
define('FM_HOST', '127.0.0.1');
define('FM_FILE', 'Product Catalog');
define('FM_USER', 'esmith');
define('FM_PASS', 'm4rg0t');
#
# this is the include for the API for PHP
require_once ('FileMaker.php');
#
# instantiate a new FileMaker object
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
#
# create a new search transaction
$request = $fm->newFindAllCommand('web_invoice');
#
# execute the search transaction
$result = $request->execute();
#
# check for errors
if (FileMaker::isError($result)) {
die('<p>' . $result->getMessage() . ' (error ' . $result->code . ')</p>');
}
#
# Get the layout as an object
$layout_object = $result->getLayout();
#
# Get the field as an object
$field_object = $layout_object->getField('items');
#
# Get the max number of repetitions from the field
# (NOTE: this is the number of repetitions defined
# in the field options dialog for the field - NOT the
# number of reps visible on the layout.)
$max_reps = $field_object->getRepetitionCount();
#
# Output to browser
echo 'Items can have a max of '. $max_reps .' repetitions.';

Question 35
I have a FileMaker Server Advanced Trial version: 9.0.3.325 on a windows 2003 server.

I have found a "bug" in a PHP API, in fact when you do a search, with a php page, some special charaters (like é, ç,...) acts like wildcards.

So FileMaker considers some charaters like : é, ç is equal wildcards * or @.

I have a file and database to explain you the problem with your API PHP. You can try it in attach file.
Try to search
User: ==ééé;
Pass: anything

and it returns all records ....!

Can you help me? Have you a solution?
Answer
I was able to reproduce the behavior you are experiencing. I admit that it is bizarre and I will continue to look into it, but the quickest solution for you is to filter your input. This is something you should be doing anyway, so I don't really consider it a work around. It's considered a security risk to pass POST data (or any user data for that matter) to the database. The following lines can be used to trap for non-alphanumeric characters:

if ( !ctype_alnum($_POST['USERNAME']) or !ctype_alnum($_POST['PASSWORD'])) {
die('Only alphnumeric characters are allowed in the username and password fields.');
}

Of course, this won't solve your problem if your fields contain é or ç but it's the best I can do for now. I will let you know if I ever figure out what the deal is with the ééé, etc...
Question 36
Hello Jonathan,

I am using Filemaker Developer 9.0 with a Windows Vista. I have experienced problems with Windows Vista and suspect this problem might be associated with it.
I designed several runtime applications, most recently using the Filemaker 9.0 Advanced. I use MindVision Installer Vise 3.0 to install my Filemaker Runtime applications on the end user's operating systems.
I tested the program and everything seems to be installed properly and function as usual, except for this dialog; "The account and password you entered cannot be used to access this file. Please try again. filemaker.com/intl.
I designed this application to include a start up script which loads a default password. I enter all of the passwords associated with this runtime application and cannot access it after the install.
I upgraded from Filemaker Pro 7.0 Developer to Filemaker Pro 9.0 Developer several months ago.

Any help would be greatly appreciated.

Steve
Answer
Thank you for your inquiry. I really know nothing about Vista or MindVision, but I have a couple of questions. Can you launch the runtime right after you create it? Or do you only get the login error after installing the runtime with MindVision? If you can launch the runtime manually -- prior to creating the installer -- I would suspect that MindVision is the culprit. Other than that, I don't know what to suggest. Sorry!
Question 37
I have a PHP form that is loaded on my server and on my clients server. The page works on my server but it does not work on my clients server.

I receive the following error message when trying it on my clients server.

Fatal error: Call to undefined method FileMaker_Error::getFirstRecord() in /Library/WebServer/Documents/Bluewater/browserecords.php on line 117
Answer
Well, I am not sure what's causing it, but the page on your clients server is returning an FileMaker_Error object instead of the expected FileMaker_Result object. See this question for more info.

The most likely cause of the issue is a connection error. I betcha that the host param of the FileMaker object is different in your client's server environment, so his page can't find your server.

Another possibility is that the OS level file permissions of your PHP pages. Occasionally when you transfer files from one box to another, the file permissions will get changed in a way that prevents the web server from accessing them. For example, you might have a config file that is no longer readable by the other pages that are trying to connect to the database.
Question 38
First of all, just wanted to tell you that your book is great! I wrote my first functional PHP script - and with FileMaker integration - in only one evening!

I have a couple of questions:

1) I'm using FMS9 on both a PowerMac G4 (Tiger) and a Dual-CPU PowerMac G5 (Leopard; with 3GB of RAM). On both machines, "java" and "fmserver" often uses as much as 70% of CPU and at least 1GB of virtual RAM when idle. And over time (~6-8 hours), all physical RAM is used up. These machines are only used for FMS PHP web publishing, serving a ~1.2GB .fp7 file. Is this behaviour normal?

2) I have a HTML/PHP search form which returns some records. If there're lots of records to be returned, how can I limit each page to show only 20 results, with a "Next" link to display the next 20 results?

Thanks!
Question 39
Im getting an error message:

Fatal error: Call to undefined method FileMaker_Error::getRecords() in /Library/WebServer/Documents/tss/RAR.php on line 19

FOR the following page called RAR.php, based on the example code in Chapter 6 -> Viewing Filemaker Data ->Retrieving All Records on page 95-97 of "Web Publishing with PHP and Filemaker 9" (Jonathan Stark :] )

Before you view the code i realise some tags may be unneccessary ie set property. The main problem is the getRecords() command. yes the connection object ($fm = new Filemaker blah blah) is functional and yes the layout has the fields and so on. everything on the filemaker server is neat and beautiful. Whats going on? Whats worng with my method?


--------------------------------- RAR.php---------------------------------
<?php <-this is line 1 and so on.
define('FM_HOST', '10.15.216.75');
define('FM_FILE', 'StaffD');
define('FM_USER', 'Touch');
define('FM_PASS', 'touch');
#2nd approach (including either C&P method
include ('FileMaker.php');
require_once ('FileMaker.php');
#Create New FILEMAKER connection object for particular user
$fm = new FileMaker (FM_FILE, FM_HOST, FM_USER, FM_PASS);
#different approach to defining FM Layout Object/s
$fm->setProperty('database', 'StaffD');
$fm->setProperty('hostspec', '10.15.216.75');
$fm->setProperty('username', 'Touch');
$fm->setProperty('password', 'touch');
#Creating Method to process object
$findCommand =& $fm->newFindAllCommand('Data');
$result = $findCommand->execute();
$records = $result->getRecords();
#Error Message Compiler
if (FileMaker::isError($result)) {
echo "<p>Error: " . $result->getMessage() . "</p>";
exit;
}
#loop through records compiling row html
$rows = '';
foreach ($records as $record) {
$rows .= '<tr>';
$rows .= '<td>'.$record->getField('Code').'</td>';
$rows .= '<td>'.$record->getField('Name I Surname').'</td>';
$rows .= '</tr>';
}
?>
<html>
<head>
<title>rar</title>
</head>
<body>
<table border="1">
<tr>
<th>Code</th>
<th>Name I Surname</th>
</tr>
<?php echo $rows; ?>
</table>
</body>
</html>



THANKS (not from RAR.php)
Question 40
I have a php add records form that was generated by the PHP site assistant. There are two instances where the data received from the form is being posted into the wrong filemaker fields. I have checked and double checked the form fields and they are displaying correctly and appear to be coded correctly. Everything works fine but the data shows up in the wrong fields in filemaker.

any ideas?
Question 41
hi

read your book and it was very helpful.

Question:
i have a form to submit a new record to FM database. everything is workign fine. I am trying to figure out how to show the fields i submit on a response page. Much like a receipt for the submission. how can i post a new record to the database, then be able to show some fileds of that submission on the response page. on ecrucial field is the time stamp of submission. please help thanks
Dave M
Question 42
I am not much of a computer guy. I have been building a database for my company using filemaker adv 8.5. There is three tables I am dealing with in this problem. Table Types, Machines, and Equipment Rented. The PK in table types is a FK in table Machines. The PK in table Machines is a FK in table Equipment Rented. Using a portal layout for Table Equipment Rented, Equipment Rented::Type is a drop down list that displays all values for Types::Type from which the user can select the appropriate type of machine. Based upon the Type value selected, the next field which is another drop down list displays only the related records from Equipment Rented::ID from which the ID of the machine can be selected. This basically narrows down a few hundred machines to maybe a dozen. Thus each machine has a unique ID number and each machine has a type to describe basically what the machine does. I have been able to get these to fields to work in my layout. The problem is with the last field. It is Machines::Name. The Name column in the Machines table contains the exact name of the machine, which is not unique, but very specific where as the Type is very generic. Once the Type is selected, the Name field reflects the first record in the Machines table. It does not change once the appropriate ID is selected. I need the Name field to reflect the appropriate name for the ID selected. It will do this correctly if I do not use type to filter the records and just enter the machine ID. But I cannot remember hundreds of machine ID's. I can look at a dozen ID's and know which one I want to select.

Any help would be...well helpful.

Thanks for your time.

Charles
Question 43
Hi Jonathan,

In your fine book you suggest keeping connection info above the web root directory. How do I actually write the path to the private directory?

I'm hosted at fmgateway but their support just said to keep the connection files in the httpdocs directory.

The directory structure looks like this

httpdocs (this is the web root)
httpsdocs
private (this is where I want to put the files)

Thanks

Pete
Question 44
HI Jonathan,

I have the below interesting question for you,

1. I have a filemaker file in client server with table name "table1"
2. I have few records in that table,

Name No

AA 1
BB 2
CC 3

3. I like to create a page,

3.1 which can receive data from the other page
3.2 Assign that received data to a specific field in the same page
3.3 find that record and show the result in the same page. Please note "in the same page"


For example
-----------

1. I will pass (thru url passing - page1.php?name = 12) the value "12" to the page1.php
2. I will find & show the records using the value that I got from the last page (thru url passing - page1.php?name = 12)

Known Solution
--------------

1. I can able to do this operation with the help of submiting this page to the other one. But I can't able to get the value,find the record & show the result in the same page itself.

This is one of our client urgent requirement.

Could you please help me ?

Thank you.

Regards,
Hari
Question 45
Hi Jonathan, thanks for all the scrips on your site. I was playing with the FMP to iCal script and it seemed it does not work anymore correct on iCal3. There must have been some changes. Do you know how I can get it to work? It seemed they changed the all day events and other minor things.

Thanks
Thomas Marinello
Question 46
Dear Jonathan,

Thankyou for the excellent book "Web Publishing with PHP and FileMaker 9". I've read through quite a large portion of your book, your hints/alerts/gotchas are great as I've started understanding some of the code FileMaker server 9 PHP tool generates to build php pages.

I do have a question though regarding Value lists. Is it possible to create dynamic valuelists related to a previous value using arrays?

i.e if I have a form with two value lists, Type and Animal(values displayed depend on whether type has the value land or water).

If the field type has the value "land", then the values displayed in animal should drop down to include, "Lion, Tiger, Cheetah"

Alternatively if type field contains the value "water" I want "Shark, Dolphin, Whale" to be displayed.

My aim is to try and recreate this FileMaker behaviour (I have this form already working in FM using the related feature when generating valuelists) on the web without using the submit button using the valuelist in FileMaker called animal.

Many Thanks

AJ
Answer
Hi AJ -

Great question. I sense some JavaScript in your future ;)

JavaScript really the only way to do what you want without involving a submit button. There are three basic techniques that come to mind to address your need. Here they are listed in order of "simple to build but clunky" to "tough to build but elegant":

1) Pull just the data for the first value list on the first page load. Add an onchange handler to the first popup that resubmits the page to pull the appropriate values for the second value list. This option requires the least bit of javascript, but does cause the page to refresh which is not pretty, especially if the user is scrolled down the page.

2) Pull all the data you need for both value lists on the first page load and store it in a javascript variable. Write an onchange handler for the first popup that reads the values from the array and writes the appropriate values to the second list by modifying the DOM in memory. This is nice in that it doesn't require a page refresh, but if you have a ton of data or complex branching logic (more than two value lists) it is not a good option. There isn't a ton of javascript involved, but it's not a trivial amount either.

3) Pull just the data for the first value list on the first page load. Add an onchange handler to the first popup that uses AJAX to query the database and pull the data for the second popup, and then writes the appropriate values to the second list by modifying the DOM in memory. This option requires advanced javascript, but is the most elegant option because the page context is not lost as with option one, and you are not limited by size or complexity constraints of option two.

As far as examples of each technique, I am working on an article for FileMaker Advisor that covers this topic and I will let you know when it is available.

Thanks,
j
Question 47
must be simple, but I feel i'm banging my head against a wall.
How do I get numerical input from text valuelist? ie, valuelist asks London, Paris, Washington but data entry is 1,2, or 3 ?
Answer
Hi there -

Funny you should ask. I just wrote an article on that exact topic here:

http://my.advisor.com/doc/19408

HTH,
j
Question 48
I have a DB with 27,000 real estate listings. Created with Site assistant and modified a little.

Doing a search provides a number of records in list view (say we find 500).
Clicking next will go to the next set of 10. As it should.
Clicking a link will provide the detail page. As it should.
Clicking back in the browser shows the all 27,000 listings not the second set of 10 as it should. It shows the second set of the 27,000 listings.

Clicking Back botton again sometimes provides the second set of 10 of the original 500. This will also ask you to re-post the data.

Any suggestions?

Also: Periodically the price of the house will show up as zero and some times it will show up correct????? Periodically, not all the time.

Here is the formating for that field. It is the same on the detail page and works all the time????

Code:

<?php echo nl2br ($english_format_number = number_format($record->getField('List Price', 0),0));




Thanks

Site link:
Link to the Site www.MLSMAX.com
Answer
Hi Tom,

I am afraid that there is no simple solution to your main question about the paging behavior of your system. Paging through results is actually a much more complex topic than most people think. For example, what should happen if you are paging through the records and someone adds a record? Furthermore, what if the records are sorted?

Also, the PHPSA search implementation leaves a bit to be desired, in that the developers chose to use POST to search the database. This is what is causing the "Would you like to re-post?" dialog. One would think that search requests would be sent using GET.

I am afraid your options are to either live with it, or get under the hood and make some fairly substantial modifications.

Regarding your other questions, I would need to know more to attempt to debug those issues.

Sorry not to be of more help,
j
Question 49
I have a filemaker calculation that uses the carriage return character, ¶, to delineate lines. However when I display that field in a web page using php, the carriage return characters are not being interpreted correctly resulting in the fm field contents being displayed on one line. I've tried to use a concatenated text field in the fm calculation where that field contains the typed <return> key. no difference in web page display though. i've looked for control character use within the fm calculation - but no luck their either. i also tried field encoding using Unicode.
any idea how i can get the carriage return character to be interpreted correctly by the web page?
any feedback would be greatly appreciated.
thank you, greg
Question 50
I have used PHP Site Assistant to create my forms, which works very well. When I have created a set of checkboxes pulling from a value list, the list does not have line breaks after each value. Is it possible to edit the code created by PHP Site Assistant to include the line breaks? The code that the assistant creates is convenient, especially if I have a larger value list. I would prefer this method rather than coding in each value by hand.

<td class="field_data">
<?php getInputChoices("checkbox", $layout->getValueList('New Vendor', $record->getRecordId()), $record->getField('PreviousStatus', 0) , getFieldFormName('PreviousStatus', 0, $record));?>
</td>

How or where would I add my line break to the above auto-generated code?
Question 51
I am trying to build a very simple entry form using FileMaker and the PHP Site Assistant. On this form I have value list I want to display using radio buttons for choices.

When I preview the web page the value list runs in a row. I would like to display one choice under another choice.

I am editing the page in Dreamweaver CS3. Is there a way to make this work? Can't figure this out.
Question 52
Hi,

My question relates to the usage og "setLogicalOperator()" in FM9 php API.

According to FileMakers manual p 35, the setLogicalOperator should work with Compound Find. I am unable to get this to work and I can not find any examples that uses this.
I am trying to mimick a FM-client's Find/Constrain function - but as I get an "call to undefined method" when I try to use it.

Could you help me to verify whether the manual is wrong og maybe guide me through another way of simulating a "Constrain" through php?

My original search requires that I search within the same portal for multiple criteria - searching directly within portal's table will unfortunately require a lot of coding, which I would like to avoid.


Kind regards, Rasmus Roland
Answer
Hi Rasmus,

Yes, I would have to say that page 35 in the manual is wrong. Neither the CompoundFind object or the FindRequest objects explicitly contain or inherit the setLogicalOperator() method. In fact, if you call that method on either object, you will get an error. The thing is, you don't need it when using a CompoundFind because using more than one FindRequest implies an OR search anyway, just like using multiple find requests in FileMaker Pro.

See this question for more info.

Thanks,
j
Question 53
Hi Jonathan,

I am trying to perform a compound find in php / filemaker to do the following:

find all records where field1 is less than 40
or
where field2 is less than 30
and
where field3 is equal to a specific value.

Here's my code thats not working.
$compoundFind = $fm->newCompoundFindCommand('projects');

$firstFind = $fm->newFindRequest('projects');
$firstFind->addFindCriterion('field1','<40');
$firstFind->addFindCriterion('field2','<30');

$firstFind->setLogicalOperator(FILEMAKER_FIND_OR);

$compoundFind->add(1,$firstFind);

$secondFind = $fm->newFindRequest('projects');
$secondFind->addFindCriterion('field3', $_GET["q"]);

$compoundFind->add(2,$secondFind);



$result = $compoundFind->execute ();


Can you offer any help on how to achieve this?
Many Thanks,


Answer
Hi Simon,

setLogicalOperator() is not a method of the FindRequest object - it is a method of the Find object. Confusing, I know.

For simple searches, FileMaker.php gives you the newFindCommand method of the FileMaker object. This is not sophisticated enough for you needs because you are mixing AND and OR. To do this sort of thing, you need to use the CompoundFindCommand, in conjunction with it's child object FindRequestCommand. The concept is that you make a bunch of find requests (roughly equivalent to find request records in Find mode in FileMaker Pro) and you lump them all into a CompoundFind, which you then execute. So, you code might look like this:


$request = $fm->newFindRequest('projects');
$request->addFindCriterion('field1', '<40');
$request->addFindCriterion('field3', $_GET['q']);

$request2 = $fm->newFindRequest('projects');
$request2->addFindCriterion('field2', '<30');
$request2->addFindCriterion('field3', $_GET['q']);

$compoundFind = $fm->newCompoundFindCommand('projects');
$compoundFind->add(1, $request);
$compoundFind->add(2, $request2);
$compoundFind->addSortRule('Username', 1, FILEMAKER_SORT_ASCEND);

$result = $compoundFind->execute();


The fact that you are using two find requests implies an OR (just like in FileMaker Pro). Hence the lack of a setLogicalOperation() call.

HTH,
j
Question 54
Hello Jonathan,
Container field help:
I've been trying to extract a container field from one of my databases using your examples and information. to help understand the implementation, i setup a single php file in which i've combined the functionality of the two files you use. I get an error when trying to display the image. the data displayed in the browser window is this:

Icon Path URL: %2Ffmi%2Fxml%2Fcnt%2Fdata.jpg%3F-db%3DWEB_Users%26amp%3B-lay%3DWEB1%26amp%3B-recid%3D10%26amp%3B-field%3DacctPicContract%281%29

errMsgImage: Communication Error: (6) Could not resolve host: localhost%2Ffmi%2Fxml%2Fcnt%2Fdata.jpg%3F-db%3DWEB_Users%26amp%3B-lay%3DWEB1%26amp%3B-recid%3D10%26amp%3B-field%3DacctPicContract%281%29; No data record of requested type


my php code is:
<?php
require_once ('FileMaker.php');
$fm = new FileMaker('WEB_Users');
$record=$fm->getRecordByID('WEB1','10');

$IconPathURL=urlencode($record->getField('acctPicContract'));
echo '<b>Icon Path URL:</b>&nbsp;&nbsp;'.$IconPathURL;
echo '<br />';

$IconImg=$fm->getContainerData($IconPathURL);

if (FileMaker::isError($IconImg)) {
echo '<br />errMsgImage:&nbsp;&nbsp;'.$IconImg->getMessage();
die();
}

echo '<img src="'.$IconImg.'" />';
?>

i know i'm communicating with the db because i can get other fields (text type) from it, plus the container field path information is extracted and displayed in the browser. i found another 2 file example of extracting container data by building a href link for which i modified it to point to my database and that technique does extract and display the container image. However i want to use your implementation for my design.

I've been spinning my wheels trying to figure out what my issue is.
Any feedback would be greatly appreciated.

thank you
greg

Answer
Hi Greg,

It is really difficult to tell from this post what the trouble is. I am not sure if the encoding in your question was performed by the my site when you posted the question, or is actually what you pasted in to the question form. Based on the error message your I would guess that your trouble is the urlencode function. Try removing that and see what happens.

BTW - In my book, I use urlencode as you have here, but the difference is that I then go on to pass the encoded url to another page. When the web server receives the encoded request, it automatically decodes it. Since you are not passing the url to another page, you do not need to encode it.

That being said, and assuming I am right, I do not think that your code will work reliably since you are trying to store binary data in a PHP var and outputting it directly in the src attribute of the img tag. My understanding is that different browsers will react differently to this depending on the size of the image.

HTH,
j
Question 55
Hi
I bought your book and im very satisfied with it.
But i missed a section when it comes to databases with more then 100 records.
I have "large" amount of datas that is 20000 records. If i try the following:
...
$record = $fm->newFindCommand('Test');
$record->addFindCriterion ('categorie', '1');
$result = $record->execute();

if (FileMaker::isError($result))
{
dosomethingwitherror()
exit;
}

$records = $result->getRecords();
...

i never get this records (if searchcriterion points to 900 records). if i try the same with searchcriterion points to about 600 records it works fine. the layout contains about 40 fields...
and all 900 found records together are about 800kb. what am i doing wrong or whats the difference between getting/finding 600 or 900 records??

please please help me. thx!!


Answer
Hi there,

Sorry, but I do not have enough information to diagnose your trouble. You did not include your email address with your question, so I can not get in touch with you. Please contact me for more information.

Thanks,
j
Question 56
Hi

I have been playing with the idea of a Filemaker / PHP website to schedule parent-teacher conferences. The parameters are multiple teachers over multiple days with each day containing multiple slots. I am trying to make it flexible enough so that the length of the slots could be determined in the database. Ideally the parent when logging in will see all of the teachers that they can make appointments with and have a box representing each timeslot that they could click to reserve the slot. There is a fair bit of logic to apply, If the block is booked by someone else they can't change it. If the slot has been booked by them they can change it. They can only reserve 1 block per student per teacher and they can not book the same time with more than 1 teacher.

I am not asking how to achieve all of this I just wanted to describe the basic rules. I have already got it so that the parent logs in and the webpage displays the result of a portal that contains the teachers that they need to schedule an appointment with. My difficulty is displaying and allowing entry into the timeslots. Ideally the parent would see all the teachers that they need to schedule an appointment with so they can get an overview of the times available. I would like the portal to have teacher name then slot 1, slot 2, slot 3 etc. The next row would be teacher 2, slot 1, slot 2 etc. The end result would be a grid. While I know I can have a field for each slot in the teacher table I would much rather have a teacher table and then a related table for the teacher time slots. This would be more flexible but getting the portal and subsequent PHP page is where I am struggling. Essentially what I want to do is a portal within a portal. I know this is not possible in FMP but I wondered if there is a way to achieve this using PHP. I tried your JSON demo and it was going in the right direction but it seemed to be more useful for displaying data than entering it.

Sorry to make this question so lengthy but any suggestions ideas that point me in the right direction would be great.

All the best

Danny Dawson
Answer
Hi Danny,

You should just have PHP pull all the records from the TeacherTimeslot table and loop through them to create an HMTL table with the appropriate graphic in each cell. As PHP is looping though the records, you'll need to check for gaps in the timeslots for a teacher (i.e. records that AREN'T in the database) in order to put a placeholder in that particular cell. As you pointed out, each cell that does represent a record will need to "know" what TeacherTimeslot ID it contains so when the cell is clicked, the appropriate action can be taken.

IOW - When you pull your timeslot records, you are going to sort them first by teacher and next by start time. As you are looping through the records for a given teacher, you need to capture the end time of the current record, iterate to the next record and compare the end time from the previous record to the start time of the new current record. If they don't match, you are going to create a "hole" in their schedule that spans that time between the end of the first record and the start of the second. This will obviate that need for dummy placeholder records in the timeslot table. I hope that makes sense.

Thanks,
j
Question 57
I exactly used the php script form your book "php and Filemaker and I get in my localhost server the following error notice:

Call to undefined method FileMaker_Error::getRecords()

My script is as follows

<?php
define( 'FM_HOST', '127.0.0.1' );
define( 'FM_FILE', 'paracrinedb1' );
define( 'FM_USER', 'admin' );
define( 'FM_PASS', 'Domperidone' );
include ('file:///C|/xampp/htdocs/FileMaker.php');
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
$request = $fm->newFindAllCommand('Signals');
$result = $request->execute();
$records = $result->getRecords();

$rows = '';
foreach ($records as $record) {
$rows .= '<tr>';
$rows .= '<td>'.$record->getFields('ID') .'</td>';
$rows .= '<td>'.$record->getFields('Name') .'</td>';
$rows .= '</tr>';
}
?>

<table border="1">
<tr>
<th>ID</th>
<th>Name</th>

</tr>
<?php echo $rows;
?>
</table>
Answer
Hi Carl,

Thanks for your question. Check out the answer to question #12 for help:

http://jonathanstark.com/questions.php#12

HTH,
j
Question 58
8VqhZc <a href="http://ebkfkadkliko.com/">ebkfkadkliko</a>, [url=http://suttuvxiuxih.com/]suttuvxiuxih[/url], [link=http://qbgvtrfiiwzn.com/]qbgvtrfiiwzn[/link], http://towgxcfvounq.com/
Question 59
PB1PzW [url=http://groups.google.com/group/LeahOwens-qnr/web/download-ringtone-mp3.html]download ringtone mp3[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/free-ringtone-tones.html]free ringtone tones[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/free-ringtones-lg.html]free ringtones lg[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/free-ringtones-nextel.html]free ringtones nextel[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/mp3-ringtone-phone.html]mp3 ringtone phone[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/phone-ringtone-send.html]phone ringtone send[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtone-bluetooth.html]ringtone bluetooth[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtone-mp3-download.html]ringtone mp3 download[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtone-wav.html]ringtone wav[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-2.html]ringtones 2[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-boost.html]ringtones boost[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-converter.html]ringtones converter[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-file.html]ringtones file[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-for-blackberry.html]ringtones for blackberry[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-mac.html]ringtones mac[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-maker.html]ringtones maker[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-on-iphone.html]ringtones on iphone[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-usb.html]ringtones usb[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/ringtones-wallpapers.html]ringtones wallpapers[/url]
[url=http://groups.google.com/group/LeahOwens-qnr/web/send-ringtone-phone.html]send ringtone phone[/url]
Question 60
Per your answer to Question 2 how are you getting a url with a file type extension in your calling page? (I understand the $_GET global array) I'm getting the following:

<?php
require_once("FileMaker.php");

$fm = new FileMaker('myDB', "http://fmserver.myhost.com","user", "password");

$record = $fm->getRecordById("myLayout", $_GET['RecID']);
echo $record->getField("data") //where data is a container field.

/**Output with inserted pdf:
* /fmi/xml/cnt/data.cnt?-db=myDB&-lay=myLayout&-recid=169&-field=data(1)
*
* with inserted word doc:
* /fmi/xml/cnt/data.cnt?-db=myDB&-lay=myLayout&-recid=167&-field=data(1)
*
* with pasted jpg:
* /fmi/xml/cnt/data.jpg?-db=myDB&-lay=myLayout&-recid=166&-field=data(1)
*/
?>

Interesting enough if you surf to the XML output directly the browser displays the image and prompts you to use the correct helper application for the inserted files.

PHP is 5.2 on Linux FMS is 9.0.3.325 on Windows Server 2003.

thanks,
Norm Fox
Question 61
Hi Jonathan,

do you know if it is possible to change the port to connect the wpe IIS from FileMaker-PHP API?

The PHP API runs on a external server, FileMaker WPE+Server on an internal server.

Regards

Uwe
Answer
Did you try adding the port number to the hostspec?

Like so:

$fm = & new FileMaker();
$fm->setProperty('database', 'webpass3');
$fm->setProperty('hostspec', 'http://123.123.123.123:443');
$fm->setProperty('username', $user);
$fm->setProperty('password', $password);
Question 62
Hi Jonathan,

I've been dabbling with FileMakers API for PHP and have built up a small site. I'd like to put my system in production, and on our web server, a Windows 2003 Server with IIS 6 and SSL with 128bit encryption level selected.

Can you tell me if FileMakers standard API for PHP will work with this type of encryption. At present I am trying to get FileMakers sample database to work with PHP (I used the standard PHP install from FileMaker Server 9.v3, PHP 5.2.4), but I keep getting error 22 when I try to view the sample. As soon as I uninstall the certificate, it works. Incidentally when the certificate is installed SSL works perfectly with IWP.

Any help would be very much appreciated.

Many Thanks

Abs

P.S I have uncommented the line
$__FM_CONFIG['curlOptions'] = array(CURLOPT_SSL_VERIFYPEER => false);

in the filmaker-api file.

Answer
I am afraid I don't have a simple answer to your question because it depends on a number of factors. Plus, I am mostly a Mac/Apache guy, so IIS is not my forte.
Question 63
I crashed a hd and used "data rescue" to get files back but cannot open them. I get "The account and password you entered cannot be used to access this file. Please try again." and I have tried every combo, hd whatever I've got that I can think of. Any ideas on how to open?using fm 8.5 on mac G3 10.3. Thank you. I haver also tried opening using a G4 on 10.4.9.
Answer
Well, you could try recovering the file using FileMaker's built-in recover function. If that doesn't work, I believe that you can contact FileMaker, Inc. and under some circumstances they can figure a way in.
Question 64
how to display a particular image in a particular time slot9
Answer
Wha?
Question 65
I saw a question below about the use of the "neq" operator. First, the PHP site assistant does not, by default, give you a "Not Equals" operator in the rendered html pages. I added the option to one of my fields. However, even though I see the "neq" -> "!=" operator show up in the "addFindCriterion" method of Find.php, the command doesn't work.

Any ideas?

Thanks
Answer
Hi there,

Surprisingly, there isn't a "not equals" operator in FileMaker. Via the web, you have to use a compoundFind with the setOmit() method of the findRequest object like so:

<?php

require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');

$request = $fm->newFindRequest('associate_layout');
$request->addFindCriterion('Account Name', 'M');

$request2 = $fm->newFindRequest('associate_layout');
$request2->addFindCriterion('Account Name', 'T');

$request3 = $fm->newFindRequest('associate_layout');
$request3->addFindCriterion('Status', 'Active');
$request3->setOmit(TRUE);

$compoundFind = $fm->newCompoundFindCommand('associate_layout');
$compoundFind->add(1, $request);
$compoundFind->add(2, $request2);
$compoundFind->add(3, $request3);
$compoundFind->addSortRule('Account Name', 1, FILEMAKER_SORT_ASCEND);

$result = $compoundFind->execute();
$records = $result->getRecords();

echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach ($records as $record) {
    echo '<tr>';
    echo '<td>'.$record->getField('Status').'</td>';
    echo '<td>'.$record->getField('Type').'</td>';
    echo '<td>'.$record->getField('Account Name').'</td>';
    echo '</tr>';
}
echo '</table>';

?>


Thanks,
j
Question 66
Using the Mailto and Open URL commands in version 9, with IWP envoked, you always get a blank browser window that comes up just before the command opens a new e-mail message.

The command I'm using is as such:

Open URL [no dialog ; "mailto:"&Sales Orders::Approved by&"?Subject=An order requires your approval....... "]

What command can I use to close the blank web page that is generated by using this command?

Much obliged for any help you can offer
Answer
Hi Barry,

I'm afraid I am not super familiar with IWP. In fact, I avoid it like the plague because it has a lot of limitations that drive people crazy. For example, I am fairly certain that there is no solution to your problem. I could definitely be wrong, but it's the kind of thing that put me off IWP in the first place. In fact, I will bet dollars to donuts that the behavior is different in various browsers. IWP demos great and is a great idea, but just never came together on the follow through, IMHO. Sorry I can't be of more help.

Thanks,
j
Question 67
Jonathan, do you know how to manipulate the operator for a specific field in a Find request? How, for example, do we search for all names beginning with "J" and ending with "K" for a field named "Author Name"?
Answer
Hey stranger - Regrettably, you didn't supply any contact info, so I can't get in touch with you. Please email me through my contact page with your email address because I have questions about your request. Thanks - jstark
Question 68
Hi Jonathan,

I tried your custom function SubtractValues ( list ; list2 ) found at briandunning.com.

It is showing function not found , highlighting SubtractValues. I added that to the function parameters. Then it is highlighting ( after SubtractValues and the dialoude box says " An operator is expected here ".

Thanks.

Sujat
Answer
It sounds like you altered the name of the custom function itself. Since the function is recursive (i.e. it calls itself) the name of the function has to match the function call inside.
Question 69
Hi Jonathan,
I have a Filemaker DB table having a field of type 'Container'
I want to upload image directly to that field using Filemaker PHP API.
I don't want to upload an image to hard-disk & entering the URL path to that field.
I'm tired of finding solution for that.
Answer
Hi jaggsr,

I am afraid that I am not aware of any good way to use a web browser to upload an image into a FileMaker container field. I suppose that you could cobble together a solution where the uploaded file landed in a "watched" directory in the file system of a machine. You could then have something like AppleScript open up FileMaker on that machine, create a new record, and insert the file. I would not recommend this solution, however, because in my experience, automating FileMaker actions on "drone" machine is very fragile. There may also be third party plugins that might help with this. You might want to look into SuperContainer from 360Works.

Thanks,
j
Question 70
Hi Jonathan,

You ecourage the use of Textmate on a Mac, with your FileMaker snippets. Do you recommend anything for us PC users, where we can use your snippets?

Many Thanks

Jalz

Answer

Hi Jalz,

Thanks for the inquiry. There are two Windows apps that I know of that reported act like TextMate on Windows:
- Intype
- E

I have not used either, but E claims native support for TextMate bundles.

Thanks,
j
Question 71
Hello Mr. Stark:

I've been attempting to get the Filemaker API for PHP to work consistently for several months now. I had it accessing a FM 9 database yesterday but when I start up my virtual machine today, I get a message indicating that the browser cannot find the filemaker.php file. No changes were made.

Do you have a definitive source on how to make this work? I've worked through the instructions in your book several times and those have not worked for me.

I've done a manual installation of PHP 5 and the FM API for PHP but the results always come back to the problem where it works for a day and then quits.

Thanks!

Rick Rose
Answer
I have had a similar problem keeping FMS and the WPE talking to each other on my development laptop. In my case it turned out that the trouble was that whenever the IP address of my machine changed, the two components couldn't find each other anymore because they were looking for the old IP. You'd think that in a single machine deployment that everything would just use the loopback address, but that's not how it works. So, the solution is to edit your server deployment. It's a minor pain in the butt, but it fixes the problem for me every time.
Question 72
I'm upgrading an old FileMaker 6 CDML web solution to FileMaker Pro 9 and the PHP API with FileMaker Server 9. I've combined all files into one multi table file and used the PHP Site Assistant to generate the basic search pages which is working fine.

The CDML site was setup so that when a new search was performed it would create a new record in a table to track searches and then the user could select articles that they found along the way which would be stored in a shopping cart. At the end of the process they could view selected articles and have them emailed to them.

Is there an equivalent with the FileMaker PHP API to search a table but also create a new record in another table which will store selected articles in a related table? I'm new to PHP and learning all of this as I go - have just also started reading your Web Publishing with PHP and FileMaker 9 which looks helpful but I'm a bit lost at this stage.

Many thanks
Andrew
Answer
Sounds like a job for PHP's built-in session handling functions. Visit php.net and start reading. I also wrote an article on PHP sessions in FileMaker Advisor magazine that might be of help.
Question 73
I have an FMP connection. Using the PHP API, I would like to do the following:

find ALL records that have the Title field containing the word "Gold" AND have the title field Containing the words "Wave 34". i can't seem to get this.

Here is my code (which isn't working):

$findCommand = $fm->newFindCommand('web__ACT_Activity__465');
$findCommand->setLogicalOperator(FILEMAKER_FIND_AND);
$findCommand->addFindCriterion('titleFull__t', "$color");
$findCommand->addFindCriterion('titleFull__t', "$searchWave");
$findCommand->addSortRule('dateStart__d', 1, FILEMAKER_SORT_ASCEND);
$result = $findCommand->execute();


Using this I get 6 records - which corresponds to just using the "WAVE 34" part?

Any help is much appreciated.

Thanks.
Answer
Hi Eric -

What's happening is that your second addFindCriterion statement is overriding your first because you are specifying the same field in each. The FileMaker API supports multiple find criteria in the newFindCommand but only if different fields are specified in each of the addFindCriterion() statements. If you think about in FileMaker Pro terms, it is totally consistent behavior. There is no way to do a search in FileMaker Pro in a single find request for both "Gold" and "Wave 34" in the same field. And therein lies the clue...

The way that you do a search for "this" or "that" is a given field is to create more than one find request. You do this in the API with the newCompoundFindRequest() object. Here's an example:


$request1 = $fm->newFindRequest('web__ACT_Activity__465');
$request1->addFindCriterion('titleFull__t', $color);
$request2 = $fm->newFindRequest('web__ACT_Activity__465');
$request2->addFindCriterion('titleFull__t', $searchWave);
$compoundFind = $fm->newCompoundFindCommand('web__ACT_Activity__465');
$compoundFind->add(1, $request1);
$compoundFind->add(2, $request2);
$result = $compoundFind->execute();
$records = $result->getRecords();


HTH,
j
Question 74
Hello,

Im working with Filemaker pro, Filemaker server and web publishing with PHP and the Filemaker API. What I want to do is display Data from portals in seperate tables in my php/html page. Ive got the php script right for the portals to be parsed and its working but when i display my php/html page, records are created where the portal data is supposed to be but no data from the portal is displayed. I checked the source code in my browser for my html/php page and it created 33 empty rows upon execution of the page which is the exact number of records that were supposed to be displayed. The only problem is they were empty rows with no data. I'm thinking it might have to do with the relationships in my filemaker database but i'm not sure. Here is the php/html code of the page:

[code removed]

Im new to PHP, but Im picking up on it very well. I have your book and It has been helping me throught the process of recreating this layout that I am working with. If you need to see a copy of the database i could send that over via e-mail. Thank you for your time and consideration.
Answer
I am not really familiar with fmStudio, so I don't think I can be of much help here. The error that you are describing sounds like it's coming from the database, not from a php file. IOW, the database might have become read-only somehow. Sometimes that can happen if you move fmp files around manually. I would first try rebooting the FMS box, and I'd probably also try editing the server deployment. Next step is to run the tests on the Server test page to make sure everything is working fine on the server side. If your code still doesn't work, you'll just have to pick through until you find the exact line that is throwin