Questions
Please use this page to post your questions about PHP, FileMaker, AppleScript, or anything else you can think of.
I do my best to answer everything in a timely fashion, but it usually takes me a few weeks to get to them all. If you are in need of urgent assistance, you might be interested in my Quick Question, Author Assistance, Consulting Clinic, or On Call services.
Question 1
echo "<img src=".$record->getField($fieldName)." />";
and it works and it seems much simpler.
Answer
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
Answer
<?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
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
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
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
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
Answer
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
<?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
Question 7
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
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
Answer
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
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
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
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
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 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
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
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
$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
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
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
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
Thanks.
Answer
Question 16
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
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
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
Question 18
Thanks,
Yoshi
Answer
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
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
Question 20
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. '&skp=0">First</a>';
if ($skp > $max) {
$prevskip = $skp - $max;
$links['prev'] = '<a href="' . $ur. '&skp=' . $prevskip . '">Prev</a>';
}
}
if ($foundcount - $skp > $max) {
$nextskip = $skp + $max;
$links['next'] = '<a href="' . $ur. '&skp=' . $nextskip . '">Next</a>';
$lastskip = $foundcount - $max;
$links['last'] = '<a href="' . $ur. '&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 . '&spc=' . $spcdat . '&qty=' . $qtydat . '';
$ur = 'details.php?fam=' . $famdat . '&spc=' . $spcdat . '&john='.'';
$statusLinks = getStatusLinks($ur, $_FMP_RSLT, $skp, $resultdat);
please i really need your help....
Question 21
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
What am I missing?
Thanks.
Answer
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
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
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
Please refer to quesiton 12 above for an explanation.
Thanks,
j
Question 25
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
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
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
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 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
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
Question 30
Jon
Question 31
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
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
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
What's the right way to do that?
Thanks
Answer
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 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
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
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
Question 37
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
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
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
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
any ideas?
Question 41
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
Any help would be...well helpful.
Thanks for your time.
Charles
Question 43
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
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
Thanks
Thomas Marinello
Question 46
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
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
How do I get numerical input from text valuelist? ie, valuelist asks London, Paris, Washington but data entry is 1,2, or 3 ?
Answer
Funny you should ask. I just wrote an article on that exact topic here:
http://my.advisor.com/doc/19408
HTH,
j
Question 48
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
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
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
<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
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
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
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
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
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
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> '.$IconPathURL;
echo '<br />';
$IconImg=$fm->getContainerData($IconPathURL);
if (FileMaker::isError($IconImg)) {
echo '<br />errMsgImage: '.$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
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
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
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
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
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
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
Thanks for your question. Check out the answer to question #12 for help:
http://jonathanstark.com/questions.php#12
HTH,
j
Question 58
Question 59
[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
<?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
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
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
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
Question 63
Answer
Question 64
Answer
Question 65
Any ideas?
Thanks
Answer
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
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
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
Answer
Question 68
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
Question 69
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
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
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
Question 71
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
Question 72
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
Question 73
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
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
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
Question 75
I have problem with my project.
I need when user click print button My page/form is print without display print dialog.
I am using PHP + javascript
Thanks
Answer
Question 76
Quick question. Been reading your PHP book, really enjoying it, certainly best value FileMaker and PHP book out there. Ive been studying your code and the code Filemakers site generator creates (although I want to write my own code I thought I could also learn from FileMaker and the php code they generate.)
Can you explain what these two lines of code are doing?
$cgi = new CGI();
$cgi->storeFile();
They seem to be on almost every page generated (apart from about 3 ). The rest code makes sense (well sort of :))
Answer
The two lines that you asked about are calling code from fmview that slice up the URL and take everything after the last slash and store it in the session variable. I don't know enough about the PHPSA to know why they chose to set it up this way, but that's what it's doing.
Question 77
Need a little assistance please. I've been reading your book doing your examples and then applying them to my system. I'm a little stuck at present although I know the code I have written works.
I have a "Customer Form" which contains a number of fields but also there is a portal called CONTACT on it with four fields. I've tried to adapt the code which is on page 95 to display all the records (I have about 3000 records in the db) on this layout.
When I call that page, it just displays a blank page. However if I remove the portal from my FileMaker layout, and rerun it, the page displays records. Now I can create a separate layout without a portal but I am trying to be as efficient as possible with my solution. Is there anyway I can use my current layout to display all the records from the master file by suppressing values from the portal as i don't need them?
Many Thanks
Answer
As you have discovered, returning a large found set with related data and lots of fields can kill your performance to the point of timeout and/or memory errors. If you are uncomfortable cluttering up your main file with a bunch of web layouts, you could consider creating a separate file that references the main file as an external reference and build them all there.
Question 78
Quite simply... how do I return only those fields which contain a NULL/empty value? I've tried all manner of variants on addFindCriterion and can't seem to get the recipe right.
A silly stumbling block but it's holding up development ... any help greatly appreciated!
Answer
Question 79
I have a question regarding editing related records. Reading through your book, you're php pages take you to a another page when editing a record.
What I am trying to achieve is to try and remain on the same layout, so is there anyway possible where I could actually edit the records in the "list" view (like when you add a new related record).
Thanks
Answer
It would be a bit nicer if you'd like to allow users to edit data on the list view, but there are some serious ramifications to this. Technically, you could make your list view a huge form where each table cell contained an input field with the field content displayed as the default value. Users could make changes and then click a Save button at the bottom of the form. The problem with this is that saving your changes mean submitting ALL of the displayed records to the database, whether they were edited or not. You could enhance this approach by making each row into a separate form, each with it's own Save button. I don't like this from a user interface perspective though because there is no visual indication as to which rows have been edited or whether or not the user's changes have been saved.
A significantly cooler, but also much more complex option is to use Ajax to allow users to edit fields in place on any views, list or otherwise. There are excellent libraries available for free that take a lot of the work out of this sort of thing for you. Check out the awesomely useful script.aculo.us library from Thomas Fuchs. There are some very helpful examples and sample code for the script.aculo.us InPlaceEditor available here.
Question 80
For some reason I dont think the databases are communicating with php.
I have run the site assistant, and the files generated by it work fine with SSL. Can you tell me if I need to make any changes?
Many Thanks
Answer
Question 81
$_SESSION['new_search']
which gets set when a user does a search of the database and creates a new record in a sessions database. There is an option to select articles as they go which get stored in a related table, kind of like a shopping cart. This is all working well so far. I now need to create a link that will let the user do a new search and create a new record in the sessions database. I've been playing with using:
unset($_SESSION['new_search']);
I have 2 links on the search results page to do a new search (there are 2 different search pages involved, advanced and basic):
<p class="style1"> <?php if ( $_SESSION['search_type'] == "advanced" ) { unset($_SESSION['new_search']); echo '<a href="basic_findrecords.php?-db=Contacts&-lay=web_search&">New Search (Simple)</a>'; } else { echo '<a href="findrecords.php?-db=Contacts&-lay=web_search&">New Search (Advanced)</a>'; } ?> </p>
however this always deletes the $_SESSION['new_search'] even if the user doesn't click on any of these links. Do you know a way to clear the $_SESSION['new_search'] variable only if the user clicks on one of these links?
Many thanks and enjoying your book.
Regards,
Andrew
Answer
Anyhoo... It's tough to tell from just these snippets, but I'd say that you need to move the unset to the appropriate "findrecords" page. The way you have it set up here makes me think that you are thinking of it more like a javascript onclick handler, which as you've discovered, is not the way it works ;-)
Question 82
I'm new to PHP so this will hopefully be a dumb question.
I'm using the FileMaker API for PHP. I've created a basic site using the Site Assitant. When you search the database you get the list of found records on the recordlist.php page. When you click to view an individual record details you go to browserecord.php. If you click the Back button in your web browser to logically go back to the list of search results instead of taking you back to your recordlist.php results page at you get the "Webpage has expired" error.
Is there a reason for this? How can I go from viewing a specific record back to the list of search results?
Also related to this on the search page I have several fields that the user can search on, one of them as follows:
<td class="field_data"><input type="text" size="30" name="<?php echo getFieldFormName('Score', 0, $record);?>" value="<?php echo $record->getField('Score', 0) ;?>">
I would like to modify this so this field is searching for "greater than or equal to" for this Score field automatically behind the scenes (not sure what the default operator is?). I'm not sure where to add the necessary PHP code to make this happen and would appreciate anyone's help with this.
Thanks,
Steve
Question 83
I'm experienced with PHP & MySQL but new to FMP9. I thought using FMP9's new ESS feature would be a great way to access the MySQL data on the server with the powerful reporting and GUI of FileMaker. And it works great with most of the data but currently unsupported are the MySQL binary data types (blob). I'd like to be able to put small web ready images in a container field in FMP and have them pushed to MySQL. This seems slightly related to question 69 on your questions page. Can you think of any work around to get JPGs in Filemaker pushed to the website either into MySQL or the web site's file system? Maybe with a WebViewer in my layout and handle the upload with PHP?
I'd be very interested in your approach to this problem.
thanks, ---Ian
Question 84
I'm working my way through you're book and enjoying it so far. I'm using the FileMaker PHP Site Assistant to kick start my site and have come across one small issue. I would like to use radio buttons on my search page that are NOT using a FileMaker valuelist for the options (mainly so I can space them out on separate lines and have difference values for what is displayed on the page and what is submitted) as follows:
<input type="radio" name="<?php echo getFieldFormName('Consumer_sum', 0, $record);?>" value="">Show all records
<input type="radio" name="<?php echo getFieldFormName('Consumer_sum', 0, $record);?>" value="Yes" checked>Only show records with summaries
However this isn't working when I search - I believe I've tracked it down to the following line in the fmview.php include file:
case 'RADIOBUTTONS': {
getInputChoices("radio", $field->getValueList(), $fieldData, $fieldSubmissionName);
break;
This is the only radio button that I'm using so I'm happy to edit the fmview.php file but I have no idea what the excerpt above means, but I think it's looking for a valuelist to use. Are you able to interpret that and let me know how to change it?
Many thanks,
Mandy
Question 85
$blogDB = new FileMaker($DB_NAME, $DB_HOST, $DB_USER, $DB_PASS);
if($blogDB = 0)
echo "Connection is established";
elseif($blogDB > 0)
echo "Connection is not established";
Even then i am not getting any message.Please help me out and i am not getting the connection from php to fileMaker.
Answer
When the "new FileMaker()" code executes, a PHP object is created in memory and that's it. A connection to the specified server is not created until you actually send a query. To actually test the connection, you need to send some query to the server. I might do something like request a list of available databases, like so:
# Instantiate a new FileMaker object
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
#
# Get list of available dbs
$result = $fm->listDatabases();
#
# Check for errors
if (FileMaker::isError($result)) {
echo $result->getMessage();
} else {
echo "Connection is established";
}
In addition to the fact that the new FileMaker line doesn't return a TRUE or FALSE (0 or 1) result, there is a logical error in the code you sent:
if($blogDB = 0)
echo "Connection is established";
elseif($blogDB > 0)
echo "Connection is not established";
Even if the new FileMaker command returned a TRUE or FALSE (0 or 1) result, the equality comparison operator in PHP is == (double equals sign) as opposed to = (single equals sign). The single equals sign is the assignment operator, so your code is setting $blogDB to 0 in the IF conditional. Even though this isn't the right approach for your situation, here is the logically correct version:
if($blogDB == 0)
echo "Connection is established";
elseif($blogDB > 0)
echo "Connection is not established";
Question 86
I am getting problem in deleting the record, which is supposed to be the easiest part in FM PHP API,just i need to execute delete command.
I have done in the given below manner-
<form method="post" action="editPost.php?id=<?php echo $post->getField('postId'); ?>">
<input type="hidden" name="action" value="deleteEntry">
<input type="submit" name="button" value="Delete Record">
</form>
if(POST('action') == 'deleteEntry') {
$result = $post->delete();
if(FileMaker::isError($result)) {
$message = 'Error deleting your record: .$result->getMessage();
}else{
header('Location: go to some other layout.php');
}
}
From this post and action i am not able to transfer my value from form to if condition.The code is simple,not getting why its not working.
Thanks and Regards
Question 87
I am working on a PHP/FileMaker website using FileMaker API for the database connection. Now my problem is FileMaker API returns error while saving the text to the database having the following characters: â â â â (single and double quotes). But it is working fine for: " " ' '.
Also if any of the following characters:â â â â are present in the databese then it is showing some special characters like:ââ¬Å ââ¬Â ââ¬Ë ââ¬â¢ while retrieving and showing the same in the website.
Please help.
Thanks in advance.
Jyoti
Question 88
great site by the way and a big help sometimes ...
I do have a problem with FileMaker and keyboard shortcuts on the Mac.
My users want to paste text into fields without any format. This could normally be done by using cmd-alt-v instead of cmd-v. But if you are using custom menus this shortcut is not working any more. And all my databases do make use of custom menus.
Do you have any clue what I can do to make this work again - and I do not want to format every field with a calculation that removes text formattings. Besides sometimes the user want to format sth.
regards
guido
Question 89
I have a situation where i have done one search and got the result set.From this result set i want to do one more search,which means my second search is dependent on first search and has to pick data from the first search value.
For this condition, i want to create a temporary table and put the data of first search in temporary table and proceed for second search.Once second search is done then delete the temporary table.
Is it possible to create temporary table,or do i need to proceed with the procedure of creating a new layout, putting the data of first search in the newly created layout and then while doing second search need to refer the created layout and as well newly created data.
Waiting for reply.
Thanks n regards.
Question 90
In chapter 10 when switching to "View as Table" I'm not asked to save, nor does the page update in the web browser. Using the DB from the examples. What did I miss?
Question 91
I have one small doubt, how to give access permission to the users using FMPHP API.Suppose i want to restrict some user from writing the information to the application.How to proceed with this?
Not getting any information regarding restricting users with reading and writing permissions.
Thanks and regards.
Question 92
I'm trying to sort some records based on their list price. The problem is that the ww_listPrice field is a string datatype (not sure why, the FM DB was developed by someone else who's unavailable at the moment), so the records are being sorted incorrectly for our purposes (e.g. £11,850, £12,850, £17,500, £6,850, £9,850).
In the bad old days of ODBC/SQL I'd use "ORDER BY VAL (ww_listPrice)"... but there doesn't seem to be an equivalent way to manipulate the addSortRule command in the PHP API. Is this correct? Do I need to perform a further sort on the returned records to achieve the desired result?
Many thanks
Nick
Question 93
Another one for you ... I'm tying myself up in knots with this one!
I'm translating a formerly-ODBC keyword search facility into FM PHP on our site. The idea is that several fields (e.g. productTItle, description, artist etc) are checked against the array of keywords entered by the user; however only those which DON'T have 'no' in the field 'showOnSite' and 'Publications' in the field 'category' are returned to the browser. This was fairly straightforward with SQL but is proving trickier with the PHP API. I was putting together a compound find like this, the idea being that I could do a logical OR search on the fields and then filter out the non-showOnSites and Publications:
//////////// SEARCH FROM INVENTORY /////////////
$compoundFind = $fm->newCompoundFindCommand('INVENTORY');
$compoundFind->setLogicalOperator(FILEMAKER_FIND_OR);
$x=1;
foreach ($sArrWords as $word) {
${"findRequest_".$x} =& $fm->newFindRequest('INVENTORY');
${"findRequest_".$x}->addFindCriterion('productTitle', $word);
${"findRequest_".$x}->addFindCriterion('productArtist', $word); ${"findRequest_".$x}->addFindCriterion('productDescription', $word);
${"findRequest_".$x}->addFindCriterion('workMedium', $word);
${"findRequest_".$x}->addFindCriterion('workProvenance', $word);
${"findRequest_".$x}->addFindCriterion('category', $word);
$compoundFind->add($x, ${"findRequest_".$x});
$x++;
}
${"findRequest_".$x+1}=& $fm->newFindRequest('INVENTORY');
${"findRequest_".$x+1}->addFindCriterion('showOnSite', 'no');
${"findRequest_".$x+1}->setOmit(TRUE);
$compoundFind->add($x+1, ${"findRequest_".$x+1});
${"findRequest_".$x+2}=& $fm->newFindRequest('INVENTORY');
${"findRequest_".$x+2}->addFindCriterion('category', 'Publications');
${"findRequest_".$x+2}->setOmit(TRUE);
$compoundFind->add($x+2, ${"findRequest_".$x+2});
// execute compound find
$result=$compoundFind->execute();
//////////// END SEARCH FROM INVENTORY /////////////
... Only the compoundFind object doesn't support the setLogicalOperator method, and even if it did I'm struggling to understand the logic of how those setOmit filters would work in an OR query. So I fear I'm heading up a blind alley and am a bit confused as to how to progress. Any help greatly appreciated!
Many thanks
Nick
Question 94
I am working on a simple web site to sell a few of my products. I would like to be able to read the database from the website to grab prices, descriptions and most importantly stock availability.
The web server runs Apache and supports PHP and MySQL.
In a perfect world, everything would be live. However, I could accept having two databases (one in the store and one on the website) and simply sync them once a day or so if need be.
Are either of the scenarios possible?
Thank you,
Scott
Question 95
http://servername/recordlist.php?-action=find Surname="Smith"
(this doesn't work - the action is right but not the rest)
Where Surname is a field in the database. I have a web page that isn't php and just has a single search field at the top (like those google searches you see everywhere). I want to be able to type a surname in there, hit return, and display the results from the database without building a php page for the search (it's our web site home page). I was using Witango to access FM until I moved to php and this allowed the url to include the search terms.
Thanks Paul.
Question 96
I am stuck with finding date range.Suppose i want to find the data with in the given date range.I am trying like this...
$request = $fm->newFindRequest('List');
$request->addFindCriterion('StudyDate', '>05/30/2008');
$request->addFindCriterion('ProviderReferring', $_GET['proname']);
$request2 = $fm->newFindRequest('List');
$request2->addFindCriterion('StudyDate', '<06/30/2008');
$request2->addFindCriterion('ProviderReferring', $_GET['proname']);
$compoundFind = $fm->newCompoundFindCommand('List');
$compoundFind->add(1, $request);
$compoundFind->add(2, $request2);
$compoundFind->addSortRule('StudyDate',1, FILEMAKER_SORT_DESCEND);
$findPostResult = $compoundFind->execute();
where i am going wrong?
Answer
Your code is set up as a compound find, which is always an OR search. IOW, you are asking FileMaker to return any records that are greater than the first date OR less than the second date. Clearly not what you want. The good news is that the solution is simple: just use a simple findCommand with the ... range operator like so:
$request = $fm->newFindCommand('List');
$request->addFindCriterion('StudyDate', '6/1/2008...6/29/2008');
$request->addFindCriterion('ProviderReferring', $_GET['proname']);
$result = $request->execute();
Note that I moved the dates by one day because the ... range operator is inclusive.
HTH,
j
Question 97
I have a FMP Server that I'm managing using external authentication.
I myself have a local admin account, as I've seen generally recommended for FMP.
But on a few of the dbs on that server, the situation calls for me to designate others (who are authenticated via external server) to use the full admin access privilege set.
So they have full admin access... except they can't seem to create new accounts. After they log in successfully, create the new acct and hit "OK", the "Confirm new access login" box will not accept their username/password. I've tried this with 2 accounts, and have logged in several times with each to make sure it's not a password issue. I've also tried doing this from machines running both fmp 8 and fmp 9.
Is there a trick you know of to get this to work? I haven't found anywhere in the FMP documentation that it SHOULDN'T work, though I have found warnings that say "if you do this, and someone gets your physical file, set up an osx server, and use the same group name they can get full access". For these dbs, I don't care. I just need to be able to do it. Maybe there's a security setting you have to check to allow it?
Thanks.
Question 98
If I search for a RefNumber that I know is in the database - it works fine.
but if there is no matching RefNumber I get this nasty error:
Fatal error: Call to undefined method FileMaker_Error::getRecords() in /Library/WebServer/Documents/awards123/catalog/badge.php on line 23
I know there must be some detail that is missing... but what is it?
Thanks,
Alan
<?php
session_start();
include ('inc/ser.php');
if(isset($_POST['submit']) and $_POST['submit'] !='') {
$search = $_POST['badgeref'];
$request = $fm->newFindCommand('wstdprod');
$request->addFindCriterion('RefNumber', $search);
$result = $request->execute();
$records = $result->getRecords();
$found = $result->getFoundSetCount();
$messerror = '';
}
if (FileMaker::isError($result)) {
die ('<p>' . $result->getMessage() . ' (error ' . $result->code . ')</p>');
}
if ($found=='1') {
$messerror="One Record Found";
// header ("Location: " . "rebadge.php?recid='.$records->getRecordID().'");
}
if ($found==!'1') {
$messerror = "No Records match your request";
}
?>
Answer
Question 99
I was trying to upload file from client(local)machine to server machine.I was using this piece of code.I am getting error message as 0 which tells (UPLOAD_ERR_OK - Value: 0; There is no error, the file uploaded with success).Meaning my file upload is working fine according to error message.But on server machine i could not able to locate my file. Is there any permission problem or what i could not able to figure it out.
sample_upload.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>File Uploading Interface</TITLE>
</HEAD>
<BODY>
<CENTER>
<BR><BR>
<FORM ENCTYPE="multipart/form-data" NAME=MyForm ACTION=submit.php METHOD="POST">
<INPUT TYPE="hidden" NAME="command" VALUE="1">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
<TABLE>
<TR>
<TD>Choose File</TD>
<TD><input name="MyFile" type="File"></TD>
</TR>
<TR>
<TD COLSPAN="2"><input name="submit" value="Upload" type="submit"></TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
submit.php
<?php // FMStudio v1.0 - do not remove comment, needed for DreamWeaver support ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$DestinationDir = "/home/berber/UploadedFiles/";
$DestinationFile = $DestinationDir . $_FILES['MyFile']['name'];
if (move_uploaded_file($_FILES['MyFile']['tmp_name'], $DestinationFile))
{
echo "File uploaded successfully.";
}
else
{
echo $_FILES['MyFile']['error'];
}
else
{
$DestinationDir = "/home/berber/UploadedFiles/";
$DestinationFile = $DestinationDir . $_FILES['MyFile']['name'];
if (move_uploaded_file($_FILES['MyFile']['tmp_name'], $DestinationFile))
{
echo "File uploaded successfully.";
}
else
{
switch($_FILES['MyFile']['error'])
{
case 1 : echo"The uploaded file exceeds the upload_max_filesize directive in php.ini.";
break;
case 2 : echo"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.";
break;
case 3 : echo"The uploaded file was only partially uploaded.";
break;
case 4 : echo"No file was uploaded.";
break;
case 6 : echo"Missing a temporary folder.";
break;
case 7 : echo"Failed to write file to disk";
break;
case 8 : echo"File upload stopped by extension";
break;
}
}
?>
</body>
</html>
Thanks.
Question 100
I am trying for upload file through FM PHP.For this i am selecting file though browse in my first page and then transferring the file name to next page.I want to transfer full absolute path from one page to other page when i select the file name and say submit.
How to capture the absolute file path?
any help will be appritiated
Question 101
thanks in advance,
john
Question 102
I am finishing p a web app and am stuck dead in my tracks with the following function I created:
function getFilemakerValueList($databasename,$layoutname,$valuelistname,$rid=NULL)
{
require_once('FileMaker.php');
$fm = new FileMaker($databasename,'http://192.168.14.5/','webuser','webuser');
$layout =& $fm->getLayout($layoutname);
$values = $layout->getValueList($valuelistname,$rid);
if (FileMaker::isError($values))
{
echo "Error: " . $result->getMessage() . "<br />Please click the BACK button and try again.<br />If the problem persists please call 800-662-9834 and report it to the lockdesk.";
}
return $values;
}
The line of code that is killing me is where the $vslues array is set. The variable $rid is passed to this function and has a value of 5. (I confirmed this by echoing the value right before and after $values array is set.) However, when the function is called it does not seem to pass 5 as $rid. I can't figure out why. When I hard code "5" or 5 directly into the getValueList function it works fine and outputs the correct value list options. Really wierd. What on earth am I be doing wrong?
If you have any ideas, would greatly appreciate!
Thanks much!
Rob Musseman
Question 103
Mac OSX Server 10.5.2
Filemaker Server Unlimited 9.0.3.325
PHP 5.2.4
Following directions in CWP manual (both Library/WebServer.. AND usr/lib ......
1 the web server root folder where your PHP scripts reside.
1 For IIS (Windows): <drive>:\Inetpub\wwwroot where <drive> is the drive on which the Web Publishing
Engine component of your FileMaker server deployment resides.
1 For Apache (Mac OS): /Library/WebServer/Documents
1 one of the include_path directories in your PHP installation. The default location for Mac OS X is
/usr/lib/php.
I get the following error outputted to my browser --from the FM_Sample Custom Web Publishing page ...
Warning: require_once(FileMaker.php) [function.require-once]: failed to open stream: No such file or directory in /Library/FileMaker Server/Web Publishing/web-server-support/test/fmi-test/phptest.php on line 5
Fatal error: require_once() [function.require]: Failed opening required 'FileMaker.php' (include_path='.:') in /Library/FileMaker Server/Web Publishing/web-server-support/test/fmi-test/phptest.php on line 5
Any Ideas?
Question 104
Error: Communication Error: (22) The requested file was not found - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.
but, database has permissions "web".
Answer
Question 105
I query a result set as follows:
$cmd =& $fm->newFindCommand('Order Entry');
$cmd->setLogicalOperator(FILEMAKER_FIND_AND);
$cmd->addFindCriterion('Ready To Be Billed', 'yes');
$cmd->addFindCriterion('Billing Export Date', '');
and at the end update the `Billing Export Date` field:
$editDate = $fm -> newEditCommand('Order Entry', $record->getRecordId(),array('Billing Export Date'=>date('n/j/Y'))) -> execute();
It updates the date fine, but the same set of records gets pulled every time. It seems that the result set only uses $cmd->addFindCriterion('Ready To Be Billed', 'yes') to find records in this case.
Answer
Question 106
is it possible through native fm scripting commands to capture in a text field the file names hosted by a particular server? Or is the user selected hosted filename returned any where during an open remote window process?
thank you
Greg
Answer
Question 107
Everything appears OK except when I try to complete the registration form on the web I get the following error "Error: 102 - Field is missing" and no record is created in the database. However, when I simple leave the web form blank and click "register" I get a successful confirmation and a blank recored is created in the database.
The only testing I've done so far is an XML access test. Here is the code from that test:
"This XML file does not appear to have any style information associated with it. The document tree is shown below.
<fmresultset version="1.0">
<error code="105"/>
<product build="01/12/2008" name="FileMaker Web Publishing Engine" version="9.0.3.316"/>
<datasource database="" date-format="" layout="" table="" time-format="" timestamp-format="" total-count="0"/>
<metadata/>
<resultset count="0" fetch-size="0"/>
</fmresultset>"
Thanks for the help.
Answer
Thanks for your inquiry.
In my experience, the 102 error is always correct. I'd need to see your PHP code to be sure, but my guess is that you have a typo in a field name.
Here are some classic gotchas:
- a space at the end of a field name
- a period in a field name
- pointing at the wrong layout
- more than one layout with the same name (and the query is going to the one that doesn't have the field)
- a plain old typo
- if you are sorting your results, remember to check those field names as well
- the user account that is being used for the request doesn't have permission to see the field
- the field is from a related file that the user doesn't have permission to access
- etc...
HTH,
j
Question 108
I've been working through your book and have altered some code for example 08_03.php. I'd like to send all the amended related data across when the user hits save. What code do I enter to pass all the amended records, not just the last record.
Thanks
A
<?php
define('FM_HOST', '127.0.0.1');
define('FM_FILE', 'Product Catalog');
define('FM_USER', 'esmith');
define('FM_PASS', 'm4rg0t');
require_once ('FileMaker.php');
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
$record = $fm->getRecordById('Product', $_GET['recid']);
if (isset($_POST['new_portal_row'])) {
$new_row = $record->newRelatedRecord('Inventory');
$new_row->setField('Inventory::Location', $_POST['location']);
$new_row->setField('Inventory::Quantity', $_POST['quantity']);
$result = $new_row->commit();
$record = $fm->getRecordById('Product', $_GET['recid']);
}
$id = $record->getField('ID');
$name = $record->getField('Name');
$model_number = $record->getField('Model Number');
$price = $record->getField('Price');
$created_at = $record->getField('Created At');
$created_by = $record->getField('Created By');
$portal_records = $record->getRelatedSet('Inventory');
$portal_html = '<form action="08_03c.php?recid=' .$record->getRecordId() . '" method="post">';
$portal_html.= '<table border="1">';
$portal_html.= '<tr>';
$portal_html.= '<th>Location</th>';
$portal_html.= '<th>Quantity</th>';
$portal_html.= '<th> </th>';
$portal_html.= '</tr>';
foreach($portal_records as $portal_record) {
$portal_html.= '<tr>';
$portal_html.= '<td><input type=text name="location" value="' . $portal_record->getField('Inventory::Location'). '"/></td>';
$portal_html.= '<td><input type=text name="quantity" value="' . $portal_record->getField('Inventory::Quantity'). '"/></td>';
$portal_html.= '<td>';
$portal_html.= '<a href="08_03.php?recid='.$portal_record->getRecordId().'">save</a>';
$portal_html.= ' ';
$portal_html.= '<a href="08_05.php?recid='.$portal_record->getRecordId().'">delete</a>';
$portal_html.= '</td>';
$portal_html.= '</tr>';
}
$portal_html.= '<tr>';
$portal_html.= '<td><input type="text" name="location" value="" /></td>';
$portal_html.= '<td><input type="text" name="quantity" value="" /></td>';
$portal_html.= '<td><input type="submit" name="new_portal_row" value="Save" /></td>';
$portal_html.= '</tr>';
$portal_html.= '</table>';
$portal_html.= '</form>';
?>
<html>
<head>
<title>08_03</title>
</head>
<body>
<table border="1">
<tr>
<th>ID</th>
<td><?php echo $id; ?></td>
</tr>
<tr>
<th>Name</th>
<td><?php echo $name; ?></td>
</tr>
<tr>
<th>Model Number</th>
<td><?php echo $model_number; ?></td>
</tr>
<tr>
<th>Price</th>
<td><?php echo $price; ?></td>
</tr>
<tr>
<th>Created At</th>
<td><?php echo $created_at; ?></td>
</tr>
<tr>
<th>Created By</th>
<td><?php echo $created_by; ?></td>
</tr>
</table>
<?php echo $portal_html; ?>
</body>
</html>
Answer
If I understand you correctly, the sort answer is that you need to use an array syntax for the input names for the portal rows. Something like this:
$html.= '<input type=text name="row['.$portal_record->getRecordId().'][location]" value="' . $portal_record->getField('Inventory::Location'). '"/>';
$html.= '<input type=text name="row['.$portal_record->getRecordId().'][quantity]" value="' . $portal_record->getField('Inventory::Quantity'). '"/>';
et cetera...
When the overall form is posted, the processing page will receive an array of records that you can loop through and send to FileMaker. This is a bad idea if you have lots of portal rows because regardless of whether or not the user has edited any rows, they all get sent back to the database. IOW - it's very inefficient.
I am planning a detailed article on this topic for FileMaker Advisor Magazine, so please stay tuned.
Best,
j
Question 109
data:text/html,<html>
<body>
<form action="http://myserver/process.php" method="post">
Name: <input type='text' name='name' />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
When I press submit I've got:
-----
Welcome
Notice: Undefined index: name in /Library/WebServer/Documents/process.php on line 3
.
You are
Notice: Undefined index: age in /Library/WebServer/Documents/process.php on line 4
years old.
-----
MY code of process.php:
<html>
<body>
Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
How could we fix that ?
Thanks in advance...
Answer
Some testing has revealed that it is an encoding issue (FileMaker's UTF-16 vs PHP's UTF-8). This could be a known issue - I just don't do much with web viewers. The only solution that I can think of is to host the form HTML on the same server as the processing page. Thanks for the excellent question.
Best,
j
Question 110
I have database wherein thousands of records are there and i want to display
the records in Pagination.
I am having problem in given below code.
:max_records tells FileMaker how many records to return
:skip_records tells FileMaker how many records in the found set to
skip, before returning results
So to do paging, we might have a "page" parameter passed to your
action and can be done this way:
PAGE_SIZE = 5 #or whatever you want...
max = PAGE_SIZE
skip = max * (params[:page] - 1)
my_layout.find(..., {:max_records => max, :skip_records => skip})
Could you please clarify the above code.How to pass the page parameter from
action .
what this denotes (params[:page] - 1) ?
Thanks and Regards,
Answer
Where did that code come from? It looks like some sort of templating system.
Best,
j
Question 111
I am running Filemaker server advanced on an Imac. This hosts a database which I built for my print brokering business. I created a PHP website for one of my customers to access delivery info from the delivery layout of the database. Everything has been working perfectly until I accidently deleted the delivery layout.
I replaced the delivery layout from a copy of the database solution that I kept. The database is fine and all the layouts are talking to each other.
Problem; When I try and access the delivery info through the internet and Wed Publishing I am getting error 105. This is suggesting that the replaced layout is missing. How do I rectify this as everything but the Web Publishing is working ok?
Answer
The first thing I would check in this situation is the name of the layout. Did you accidentally add a space after the name? Is it named EXACTLY the same way in FileMaker as it is in the PHP page? If so, my next step would be to check the security system to make sure that the user connecting via the web has permission to view the layout in question.
Good luck!
j
Question 112
We have a site created with PHP for API FMstudio, Dreaweaver, using FileMaker Pro 9.0 Advanced hosted on a new MAC leopard machine with FileMaker Server 9.0.
We need our customers to be able to upload documents from their local drive to a particular container field in our database from within a PHP page and to be downloaded (i.e. via the web PHP page) by someone else at a later stage.
I would appreciate hearing from anyone with experience either writing the appropriate script from within PHP or using a utility or Plugin?
The super Container by http://www.360works.com looks like a very good product but we need something more basic with less features.
We purchased Grab-it Plug-In from http://www.fmwebschool.com/grabit.php which based on the demonstration video on their website would provide the perfect solution. The user manual provided with the product hasn't proven to be as clear/novice friendly!!!
I would be happy to hear from anyone using that product successfully in general and particularly from within PHP? One of the problems I suspect is that I am not loading the Grab-it Plug_in correctly on FM server 9.0. Any tips about how best to load a Plug-In on FileMaker Server 9.0 would be most appreciated.
Thanks in advance,
David
Answer
Thanks for your inquiry. I understand your situation, but I'm afraid I don't have an easy answer for you. There is an entire chapter on file handling in my FileMaker/PHP book, which is too much information to go into here.
My advice would be not to use container fields. When the web is involved, they are a pain, as you are discovering. Instead of container fields, consider storing URLs to the files in text fields and display links to them in FileMaker via a Web Viewer.
If you must use container fields, you might consider the SmartPill plugin from Scodigo. It can write directly to container fields, so your web users could upload to a web server and FileMaker could periodically ping the web server looking for new files which it would then write to the container fields. Not sure that that would work - just thinking out loud. Here's a link:
http://www.scodigo.com/products/smartpill-php
Regarding the plungins that you mention in your message, I'm not really familiar with them. I have heard good things about super container, but I have never used it.
Best,
j
Question 113
Answer
Thanks for your inquiry. If you are using IWP (or XSLT with sessions enabled) your users will remain connected until they logout or their session times out. If you are connecting to FileMaker Server with PHP, the connections should close as soon as the page has loaded. If you are exceeding your limit with PHP, one of a few things could be going on:
- You have a ton of traffic.
- You are triggering FileMaker scripts that take a long time.
- Your server is not closing the connections properly.
Best,
j
Question 114
Tom
Answer
Question 115
I've built a site using the FMP Site Assistant.
It's has the following pages.
index.php(Home Page)
New Request (This takes them to a page that has them fill out 5 answers and then they submit it as a record in the database)
Search Page (This show a list of records in the database as well as has several fields to search from)
Translation Only (This is is the same as the Search page but finds a found set of translation only records.)
Update Page (This page has many other fields to fill in after they have submitted the original record)
Trans Update Page (This is another update page that has a set of fields to fill out if the Translation Only field is set to yes)
A person goes to the home page and select the new request button. That file comes up and asks them to fill out 5 fields. After that they click the submit button to create the record in the database. This then places them in the update file to finish the request process.
Here's what doesn't work.
If the translation field on the new request form is selected as "yes" I need the user to be taken to the Trans Update page. It only goes to the Update Page.
I've tried using the header function but it won't work because you have to redirect before anything is submitted. I want to submit the new request to create the record then if the translation field is selected to be "Yes" then go to the Trans Update page.
I've also tried the following in the html and it didn't work.
<?php if($_REQUEST['Translation'] = "yes") {
echo '<form action="transupdate.php?new" method="post">';
} else {
echo '<form action="update.php?new" method="post">';
}
?>
I hope this gives you what you need. I feel I'm close but the again not so close. ^(
Answer
The header function is a good solution to your problem, but I am not sure why it is not working for you. I suspect you are trying to do too much with each page. Try this:
Point the action of the form in the new request page at a new file called something like create_record.php. create_record.php would receive the incoming data in the $_REQUEST super global array and you can use that to create the record in the database normally. At the end of that page add some code like this:
if($_REQUEST['Translation'] = "yes"){
header('Location: transupdate.php');
} else {
header('Location: update.php');
}
Naturally, transupdate.php and/or update.php will now no longer have to create the record (assuming that that was what they are doing now).
GOTCHA: When using the header function you have to make sure that you have not output anything to the browser prior to calling it. If you get an error like that and can't figure out what is wrong, check for white space outside of the <?php ?> tags. A common error is to include a page at the top of the current page that has a trailing space or line return which will screw you up.
Best,
j
Question 116
I am looking for displaying Thumbnails in columns and rows in a FilMaker layout, with 3 or more commands (executing scripts) on each Thumbnails...
Thanks for helping, Leo
Question 117
I have a FileMaker layout which contains around 1800 + records and around 10 fields. I just need only one field rather than getting the entire fields from the FileMaker and storing it in a temporary variable.
Following is my code snippet:
$findCommand =& $this->fm->newFindCommand($layout);
@$findCommand->addFindCriterion("Accession#");
$result = $findCommand->execute();
$records = $result->getRecords();
Thanks in Advance,
Godson
Question 118
1. I want to perform a newFindAllCommand but only select 3 required fields out of 32 fields. How to do this?
2. I want to get recordset as a result of "Group by" (in SQL). How to do this ?
Answer
Thank you for your inquiry.
1. I want to perform a newFindAllCommand but only select 3 required fields out of 32 fields. How to do this?
All you have to do is point your query at a layout that only contains the 3 fields that you want.
2. I want to get recordset as a result of "Group by" (in SQL). How to do this ?
You are going to have to post process the result set in PHP. IOW - pull all the records you need and then loop through them to create the groupings that you want.
PLMK if you have more questions.
Best,
j
Question 119
first of all I want to apologize for my bad English as I'm a guy from The Netherlands. For some time now I've been looking around for a clean and simple solution for the bookings of my band. Untill I came across Filemaker. What a great application! But there are lot's of things that I need to learn, s there still is some work for me to do.
Now my little problem:
I'm using your "SendEventToiCal" script to get our bookings into iCal. Unfortunatelly something goes wrong. I've gone through the script dozens of times; adding something here, erasing something there but it just won't work.
Could you please have a look at the script (as I use it) and help me??
This is the script like I use it:
-- grab the data from Filemaker
tell application "FileMaker Pro Advanced"
tell current record
set theCalendarTitle to "boekingen"
set theSummary to cellValue of cell "zaalnaam"
set theDescription to cellValue of cell "betreft"
set theStartDate to cellValue of cell "optreeddatum"
set theAllDay to true
end tell
end tell
set theStartDateAsText to theStartDate
-- convert text to dates
set theStartDate to date theStartDateAsText
-- create the event in iCal
tell application "iCal"
activate
-- make new calendar if need be
set allCalendarTitles to the title of every calendar
if allCalendarTitles contains theCalendarTitle then
set theCalendarNumber to (first calendar whose title is theCalendarTitle)
else
set theCalendarNumber to (make calendar at end of calendars with properties {title:theCalendarTitle})
end if
-- make event
set theEvent to make event at end of events of theCalendarNumber
-- set the event properties
tell theEvent
set start date to theStartDate
set end date to theEndDate
set summary to theSummary
set description to theDescription
set AllDay event to true
end tell
show theEvent
end tell
Thanks in advance,
Greetings from The Netherlands
Mattheus van Zanten
Answer
Thanks for your inquiry. I am glad you are enjoying FileMaker. Regarding your trouble with my AppleScript, I think it has to do with international date settings. I've had a lot of non-US people contact me with problems. I know some have fixed the issue, but I don't know how. Try adjusting your date settings in both the operating system and FileMaker preferences and let me know what happens.
Best,
j
Question 120
$Iphone_find = $LAW_db->newFindAllCommand('Iphone');
$Iphone_find->addFindCriterion('Date', '>=//');
$Iphone_find->addSortRule('Date', 1, FILEMAKER_SORT_ASCEND);
fmsSetPage($Iphone_find,'Iphone',Iphone_max);
$Iphone_result = $Iphone_find->execute();
Answer
Thanks for your inquiry. Try this:
$today = date('m/d/Y');
$Iphone_find = $LAW_db->newFindCommand('Iphone');
$Iphone_find->addFindCriterion('Date', $today.'...');
$Iphone_find->addSortRule('Date', 1, FILEMAKER_SORT_ASCEND);
fmsSetPage($Iphone_find,'Iphone',Iphone_max);
$Iphone_result = $Iphone_find->execute();
Note that I changed your newFindAllCommand to newFindCommand.
HTH,
j
Question 121
I'm switching from OSX 10.4 server using FX PHP to OSX 10.5 using FM API.
My first question is regarding mail. On the old server I use
require_once "Mail.php";
but that gives me an error when I try to use it with FM API.
Secondly, can I use FX and FM PHP on the same machine? It would make life a lot easier to take the existing sites over and keep FX then converting them to FM PHP.
If I can I would guess I still need to modify the httpd file for FX PHP. Does FM PHP modify that as well?
thanks for the helpful book.
S
Answer
Thank you for your inquiry.
My first question is regarding mail. On the old server I use require_once "Mail.php"; but that gives me an error when I try to use it with FM API.
I don't think that has anything to do with FX of FileMaker.php. You must have a file named "Mail.php" on the old server that didn't get moved over to the new one.
Secondly, can I use FX and FM PHP on the same machine? It would make life a lot easier to take the existing sites over and keep FX then converting them to FM PHP.
You can freely use FX.php and FileMaker.php together without changing configuration of any kind. Just include the file that you want to use and go to town.
Best,
j
Question 122
I'm working on a very basic ordering system for a nationwide car manufacturer. They have an intranet for their dealers who need to order certain products from my customer.
Here's the dilemma:
How would I go about capturing an URL with an individual dealership number (supplied by their intranet) as a variable to be passed along to my solution to do a single-sign on? I'm assuming we would be using PHP's sessions?
They will logging onto their intranet then punching out to my system but they will be passing along their dealerID (passed along from logging in to the intranet) to my solution for tracking/searching purposes. I need to make sure that passed along dealerID is persistent across all my pages so I can have FileMaker create a new order for this dealerID. Just so you know, I have a database in FileMaker with a complete list of the the dealerIDs already in place with their pertinent information.
I'd need a way to capture the provided dealer ID (ie: index.php?dealerID=C12345) and store it into a session but also pass it along to FileMaker so it can do lookups on the stored dealer ID.
I also need to make sure they can only search (or list) only their past orders.
Thanks!
Answer
Yes, PHP sessions are what you want to use for this. When the user first visits your site using a URL like...
http://yoursite.com/index.php?dealerID=C12345... you can store that dealer id in their session with some code like:
session_start();
if(isset($_GET['dealerID'])){
$_SESSION['dealerID'] = $_GET['dealerID'];
}
Any pages they visit after that first request will have access to the $_SESSION['dealerID'] value, as long as the page contains the session_start() call at the top.
Bear in mind that this is a fairly insecure arrangement so if you are concerned about dealers seeing each other's information, you should consider a full blown login routine.
Best,
j
Question 123
Do Script triggers work with PHP.
And how if possible?
Answer
Question 124
Once before, the result email from my php script started to tell me "Window is missing" instead of telling me the script ran fine with no problems. I don't remember quite what I did to solve this. I think it was something as simple as a GoToLayout step at the end that returns to the layout used in the script call in php.
But now that I have upgraded to Server 10 I'm again getting "Window is missing". Do you have any ideas why?
Thanks. Happy to supply both scripts if you want to see them.
Answer
Question 125
PHP gives the following error when trying to connect to FM and perform a search:
Communication Error: (22) The requested URL returned error: 404 - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.(22)
The php code which gives this error is:
require_once('FileMaker.php');
$database = "DatabaseName";
$hostname = "192.168.1.2";
$username = "****";
$password = "****";
$connection =& new FileMaker($database, $hostname, $username, $password);
$cmd =& $connection->newFindCommand('INVOICE');
$cmd->addFindCriterion('_InvoiceID', '1003');
$result = $cmd->execute();
if (FileMaker::isError($result)) {
if ($result->code != 401) {
echo 'Error: ' . $result->message . '(' . $result->code . ')';
die();
}
else $notFound = true;
}
Let me give you some info on the server:
-Windows 2003 Server R2 Standard x64 Edition
-FM Server 10
-FM Pro 10
-PHP works, I can run phpinfo() and see all the details.
-I have a database installed, I can connect to it usinf FM Pro and browse/edit all the layouts and records, it works.
-I have created a php user account, I can use this accoutn to log in FM Pro and it works.
-I have check the username or password so many times I almost went blind.
-The FMPHP privilege is enabled.
-The PHP column for my database has a green tick.
Finally, I have searched the web for hours, any help would be much much appreciated. If you need any other piece of information about the server state/config just ask, you have my email.
Answer
Question 126
For example...
$title = $record->getField('Title');
$date = $record->getField('Date');
$summary = $record->getField('Summary');
$page = $record->getField('Page');
echo '<li><h4><a href="/'.$page.'">'.$title.'</a></h4> - '.$date. '<br />'
.$summary.'<a href="/'.$page.'"> <em>-read more.</em></a></li>';
vs.
$data = $record->getField('ck_Data');
echo $data;
where ck_Data is a calc field which uses filemaker to parse the html.
Answer
The only gotcha that you need to know about is that the FileMaker API getField() method strips HTML out of the data by default to prevent against XSS attacks. When you actually do want to retrieve HTML from the db, you have to use getFieldUnencoded().
Question 127
I've figured out how to use CWP and PHP to fire a script in FMP.
Now I want to call an external script in a second database from that first script that imports the data from the first db. No joy! 8-(
Is this not possible? Thanks!
Answer
Thanks for the inquiry. You can call an external script via PHP as long as the external file has PHP extended privs enabled. Also keep in mind that only web compatible script step are supported when calling via PHP, so Import Records is not allowed. To get around this, you could just direct a standard PHP Find query at the source (external) file and create new records in the target file in the normal fashion.
Best,
j
Question 128
I'm attempting to modify your secure login.php file that was parrt of the "Deliver Secure Web Applications with PHP and FileMaker Pro" in Advisor magazine. I'm just trying to alter the login form fields to use my CSS. Here's how I have my form at present:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
Authentication
</title>
<link rel="stylesheet" type="text/css" media="screen" href="stripes_teal.css">
</head>
<body>
<div id="container">
<div id="header">
<h1>
Login Required
</h1>
</div>
<?php $activelink = 'authentication.php'; include_once 'navigation.php' ?>
<div id="content">
<h1>
Log In
</h1>
<?php echo '<form action="' . $this_url . '" method="post">' ?>
<table class="record">
<tr class="field">
<td class="field_name">
Account Name
</td>
<td class="field_data">
<input class="password_input" name="userName" type="text">
</td>
</tr>
<tr class="field">
<td class="field_name">
Password
</td>
<td class="field_data">
<input class="password_input" name="passWord" type="password">
</td>
</tr>
<tr class="submit_btn">
<td colspan="2">
<input name="log_in" type="submit" value="Log In">
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
Your example has no table or CSS and is pretty straightforward:
echo '<form action="' . $this_url . '" method="post">';
echo ' <p>Username: <input type="text" name="user" /></p>';
echo ' <p>Password: <input type="password" name="pass" /></p>';
echo ' <p><input type="submit" name="clicked_button" value="Login"></p>';
echo '</form>';
I'm now trying to combine your logic which is working fine for me with the table/HTML/CSS values but I'm not sure how to go about this.
Appreciate if you can show me how to combine these so I get a nice looking table using my site's CSS with your logic that works a treat.
Kind regards,
Steve
Question 129
I have a site that's generally working well which requires the user to login using a FileMaker Account Name/Password. I've added a form page where they can change their password, with fields to enter their current password and new password. I then want to call a FileMaker Pro Script that simply has the Change Password script step with the old/new passwords referenced from global fields where I've stored them. It's not working at present and checking the logs gives an error 213 (User account and/or password does not exist) - even though the user has logged in via PHP successfully and created a session. I would assume it just "knows" what is the current account to change the password for.
Here's the code if you can spot what I'm doing wrong - have gone round in circles for a few hours now and can't find any other references to how to change your password when using internal FileMaker Accounts for the login system:
<?php
# Make sure the user is authenticated
require ('authentication.php');
$username = $_SESSION['username'];
$password = $_SESSION['password'];
require_once('Connections/raters.php');
require_once 'FileMaker.php';
require_once 'error.php';
ExitOnError($fm);
$layoutName = 'WebRatings';
ExitOnError($layoutName);
# Get the entered Current and New Passwords from the POST from previous page
$CurrentPassword = $_REQUEST['CurrentPassword'] ;
$NewPassword = $_REQUEST['NewPassword'] ;
# Need to find the current username's record in the Raters table
$rater_find = $fm->newFindCommand('WebRaters');
$rater_find->addFindCriterion('NameFull_c', $username);
$rater_find_result = $rater_find->execute();
ExitOnError($rater_find_result);
$layoutName = 'WebRaters';
ExitOnError($layoutName);
$recordID = $rater_find_result->getFirstRecord()->getRecordId();
# Now edit the current user's Raters record with the old and new password's into fields
$rater_edit = $fm->newEditCommand('WebRaters', $recordID);
$rater_edit->setField('zNewPassword_g', $NewPassword);
$rater_edit->setField('zOldPassword_g', $CurrentPassword);
$rater_edit->execute();
ExitOnError($rater_edit);
$layoutName = 'WebRaters';
ExitOnError($layoutName);
$record = $fm->getRecordById('WebRaters', $recordID);
# Now call the script to change the password using the values in the global fields
$cmd = $fm->newPerformScriptCommand('WebRaters', 'Change Password CWP');
$result = @$cmd->execute();
if( FileMaker::isError($result) ) echo $result->getCode().': '.$result->getMessage();
ExitOnError($result);
$layoutName = 'WebRaters';
ExitOnError($layoutName);
# Now update the session globals with the new password so they can continue to work
$_SESSION['password'] = $NewPassword ;
?>
Kind regards,
Steve
Question 130
Great site with lots of information any IT person could use.
My question might be really easy to answer but I'm looking for a plugin that does near real-time integration with FM 10 and Leopards iCal and Address book. Thoughts? Suggestions?
Cheers
Don
Question 131
I have a page that allows users to change their password (using a table login system) which contains the following variables at the top:
$NewPassword1 = $_REQUEST['NewPassword1'] ;
$NewPassword2 = $_REQUEST['NewPassword2'] ;
$CurrentPassword = $_REQUEST['CurrentPassword'] ;
$ExistingPassword = $find_result->getFirstRecord()->getField('Password') ;
They enter their current password and their new password twice and it edits the password in the Users table accordingly. I've got this working but would like to add some basic error checking to:
1. ensure they enter an existing password, and new password (twice)
2. ensure the existing password they enter matches the one already in the Users table (i.e $CurrentPassword = $ExistingPassword)
3. ensure the newPassword1 and newPassword2 are identical in case they made a type
and to stop the execution and display an error on the page if any of these conditions are met.
I'm capturing the values the user enters at the top of my changepasswordresponse.php page:
I've been looking through your book which I really enjoyed and can't find anything that relates to this.
Many thanks,
Steve
Answer
Well, I have a lot of questions about exactly how you have your solution set up. Rather than ask them, I have posted this example, which might clear things up for you. If it does not, please feel free to ping me again with a more elaborate description of your situation.
Best,
j
P.S. I'm glad you enjoyed the book!
Question 132
When someone from another part of the company (on a different subnet) tries to connect, they get to the IWP webpage, and see the list of databases, and can click on one. They then get the login screen. However, after this no matter what they do (i.e. try to login in either as a guest or with an account name), they get an error message saying that the file could not be opened by the supplied username/password.
This happens when the database is served using both FMPro and FM Server Advanced. In FMServer, I made sure the authentication was set to "Filemaker", i.e. its not set to external authentication. I also checked the accounts in the database with FMPro, and the authentication is set to only Filemaker accounts.
In the log files though, I see something very strange. When the login is denied, an entry comes up saying "authentication failed for xyz" where xyz is NOT the account name they entered on the login screen, but rather the login id of the user on the network - which Filemaker should not know anything about! Its almost as if its doing external authentication even though its not set to do that.
All pointers would be greatly appreciated, thanks,
-rs
Question 133
I've setup an editrecord.php page that when submitted goes to a browserecord.php page showing the changes to the record and has been working well. Now the customer wishes to add some logic/conditional tests in between the user editing the record based on their answers to some of the questions in the edirecord.php page (similar to a survey with yes/no answers etc).
On the editrecord.php page the user can enter Yes or No for the first 5 options (A1, A2, A3, A4, A5) or Yes or No for the next 3 options (B1, B2, B3). If they answer "Yes" to the A1, A2, A3, A4, A5 questions I would like to edit the record and take them to a page with further questions on them, and if they answer "Yes" to the B1, B2, B3 questions I would like to take them to a different page. I've got the pages designed with the questions but not sure how to add some conditional logic that directs them to the appropriate page.
I also need to do some checking/validation before they submit the page to be edited. For example if they accidentally answer questions A1, A2, A3, A4, A5 and B1, B2, B3 I need to alert them to that and not allow them to proceed with editing the page until they fix that.
Here's an example of the code that edits the record on the browserecord.php page:
if (isset($_REQUEST['-action']) and $_REQUEST['-action'] == "edit") {
# edit the record
$request = $fm->newEditCommand('WebSurveys', $_REQUEST['recid']);
$request->setField('CriteriaA1', $_POST['CriteriaA1']);
$request->setField('CriteriaA2', $_POST['CriteriaA2']);
$request->setField('CriteriaA3', $_POST['CriteriaA3']);
$request->setField('CriteriaA4', $_POST['CriteriaA4']);
$request->setField('CriteriaA5', $_POST['CriteriaA5']);
$request->setField('CriteriaB1', $_POST['CriteriaB1']);
$request->setField('CriteriaB2', $_POST['CriteriaB2']);
$request->setField('CriteriaB3', $_POST['CriteriaB3']);
$request->setField('Scale1', $_POST['Scale1']);
$request->setField('Scale2', $_POST['Scale2']);
$request->execute();
$recid = $_REQUEST['recid'];
$record = $fm->getRecordById('WebRatings', $recid);
}
This edits all fields first but my pages will now be separated into separate pages, with the A1, A2, A3, A4, A5 and B1, B2, B3 fields on the first page.
Not sure how to proceed from here?
Kind regards,
Steve
Question 134
pears
apples & oranges
bananas
(these are coming from a valuelist for that field in the FileMaker database). The problem is if that record had the "apples & oranges" already checked in the database when this record is viewed for editing there is no x next to the "apples & oranges" value (i.e. it is not checked). All other values work fine and I suspect it has something to do with the "&" character in the "apples & oranges" string. Here's the code for that field on the editrecord.php page:
<?php
$checkedValues = $record->getField('Fruit');
$checkedValues = explode("\n", $checkedValues);
foreach($fruits as $fruit) {
$selected = "";
if( in_array($fruit, $checkedValues) ){
$selected = " checked=\"checked\"";
}
$fruit = htmlspecialchars($fruit);
?>
<input type="checkbox" name="Fruit[]" value="<?php echo $fruit; ?>"<?php echo $selected;?>>
<?php echo $fruit; ?><br>
<?php
}
?>
If I edit a record that doesn't have this option checked it is getting saved back into the database correctly. It's when I go back to view and edit that record again that it isn't checked, which creates a problem when you save that record and it submits it again as not being checked when it should be checked. I just viewed the source on the page and it appears as:
<input type="checkbox" name="Fruit[]" value="apples & oranges">
apples & oranges <br>
whereas I would be expecting:
Code:
<input type="checkbox" name="Fruit[]" value="apples & oranges" checked="checked">
apples & oranges <br>
I gather the htmlspecialchars is changing the & to & but not sure how to deal with this from here?
(have enjoyed your book and still refer to when creating PHP API solutions)
regards,
Mandy
Question 135
Question 136
Question 137
Question 138
I am having trouble with the mysterious deletion of records, through CWP. I'm currently trying to make a login form, I tried a CompoundFindCommand and a simple FindCommand and they both return what I want. However, whatever they returned has been deleted from the database... And I'd like it very much if my users were able to log in more than once ^^. Here is the CompoundFindCommand code I use:
/--CODE-START--/
$username=$fm->newFindRequest('Usager_Generic');
$username->addFindCriterion('Username',$_POST['user']);
$compoundFind=$fm->newCompoundFindCommand('Usager_Generic');
$compoundFind->add(1,$username);
*result=$compoundFind->execute();
$records=($result&&!FileMaker::isError($result))?$result->getRecords():'';
/--CODE-END--/
This is followed by a few getField() methods used to validate the login's information.
Thank you very much
Question 139
Second: I've been using variations on your applescript code to move events from FileMaker 9 to iCal for a while now. I just converted my power users to 10. Yeah, I know I'm slow. Anyway the code still works in all regards but one. It doesn't seem to handle the theAllday flag anymore. It make every event a timed event. I've looked at the library for the version of iCal we are using 3.0.8 and it doesn't seem to have changed. I can't figure out why it isn't setting the event to all day. Instead it puts everything in at 12 AM. Below is the applescript. I know you haven't released a 10 version of this but I was hoping to get some help anyway.
As always thank you for all you do for the FM Community.
Ellen Reiser
==============================================
(*
Create Event
Copyright © 2005 Jonathan Stark
This script automates the process of creating iCal calendar events from FileMaker records.
You may incorporate this sample code into your program(s) without
restriction. This sample code has been provided "AS IS" and the
responsibility for its operation is yours. You are not permitted to
redistribute this sample code as "Jonathan Stark sample code" after having
made changes. If you're going to redistribute the code, I would appreciate it
if you make it clear that the code was descended from Jonathan Stark's sample
code, but that you've made changes.
Have fun!
Visit www.jonathanstark.com for
more fun with FileMaker,
AppleScript, iCal, and more...
05/29/08 made changes to apply to Target Marking -er
*)
-- grab the data from Filemaker
tell application "FileMaker Pro"
tell current record
set theCalendarTitle to "FM Projects"
set theSummary to cellValue of cell "giCal_Summary"
set theDescription to cellValue of cell "giCal_Description"
set theStartDate to cellValue of cell "giCal_Date"
set theStartTime to cellValue of cell "giCal_Time"
set theEndDate to cellValue of cell "giCal_EndDate"
set theEndTime to cellValue of cell "giCal_EndTime"
set theAllDay to cellValue of cell "giCal_AllDay"
end tell
end tell
set theStartDateAsText to theStartDate & " " & theStartTime as text
set theEndDateAsText to theEndDate & " " & theEndTime as text
-- convert text to dates
set theStartDate to date theStartDateAsText
set theEndDate to date theEndDateAsText
-- create the event in iCal
tell application "iCal"
activate
-- make new calendar if need be
set allCalendarTitles to the title of every calendar
if allCalendarTitles contains theCalendarTitle then
set theCalendarNumber to (first calendar whose title is theCalendarTitle)
else
set theCalendarNumber to (make calendar at end of calendars with properties {title:theCalendarTitle})
end if
-- make event
set theEvent to make event at end of events of theCalendarNumber
-- set the event properties
tell theEvent
set start date to theStartDate
set end date to theEndDate
set summary to theSummary
set description to theDescription
if theAllDay = "1" then
set allday event to true
end if
end tell
show theEvent
end tell
Question 140
I've got a simple FileMaker PHP API site working well. It starts with a search form (search.php) which uses the method="get" to submit the search form and view a recordlist.php page of results. This is working well, however I would like to make one small change. Whenever a user submits the search form (mixture of fields and drop down lists, e.g:
<tr class="field">
<td class="field_name">State</td>
<td class="field_data">
<select name="state_postal"><?php foreach($states as $state) {$state = htmlspecialchars($state);?>
<option value="<?php echo $state; ?>"><?php echo $state; ?></option>
<?php
}
?>
</select>
</td>
I would like them to be able to click the browser back button on the search results page and go back to the search.php page and have it remember the search criteria they had previously entered. At the moment it always clears out any previously entered search criteria and starts with a blank search form. I've Googled and can't find anything that points me to the solution (assuming it is possible as I've seen other sites that work this way).
Many thanks,
Steve
Question 141
Thanks for all the help you are giving folks with Filemaker API.
The following compound find is giving weird results. The "CouponCode" field is type Text. The "NumberStarting" and "NumberEnding" fields are type Number. I'm using a very simple form to submit a POST with an <input type="text" name="promoCode"> field. If I enter a number in a valid range for the NumberStarting...NumberEnding request, the find works. If I enter a number in an invalid range, zero records are found, as expected. If I enter a purely text value in the querry, which matches exactly the same text in CouponCode, the find always fails to find any records -- That is the problem. There is an exact text match and no records are returned. Yet if I add one or more digits to that same text in both the record and the querry, the find succeeds. It's like there is something about the purely alpha text that Filemaker does not like when mixed in a compound find with a number field. Can you see why?
Using FIlemaker Server 10; PHP 5.2.6.
Regards,
Gary
<-----code snippet: --->
$promoCode = $_POST['promoCode'];
// See if the promotion is in the database, searching by CouponCode or pro card number.
$promoFind1 = $BCA_DB->newFindRequest('Web_Promotions');
$promoFind1->AddFindCriterion('CouponCode',$promoCode);
$promoFind2 = $BCA_DB->newFindRequest('Web_Promotions');
$promoFind2->AddFIndCriterion('NumberStarting','â¤'.$promoCode);
$promoFind2->AddFIndCriterion('NumberEnding','â¥'.$promoCode);
$promoFind = $BCA_DB->newCompoundFindCommand('Web_Promotions');
$promoFind->add(1,$promoFind1);
$promoFind->add(2,$promoFind2);
$promoFind_result = $promoFind->execute();
Question 142
I have an older X-Serve running in another state. It can support Leopard. My PHP is out-dated, and it seems the Apple upgrade would be far easier than trying to upgrade Apache/PHP. So if I am to upgrade it from 10.4.11 to 10.5 Leopard (which I have in a box), what are the implications of such an installation: can it be done remotely or do I need a person with disk, keyboard and mouse? Can I expect Apache and PHP to work more or less as they do now? etc.
TIA,
Frank
Answer
Question 143
Answer
Question 144
Does anyone know if this is possible and how it could be implemented?
Many thanks,
Steve
Answer
http://www.soliantconsulting.com/blog/wp-content/uploads/2009/04/fmproxy_0v2.zip
Regarding the technique, here is a good article on the topic:
http://jaspan.com/improved_persistent_login_cookie_best_practice
Essentially, you need to store a crazy long id value in a cookie in the user's browser. The crazy long id corresponds to a record in the db that holds their login creds. Whenever the user logs in via cookie (i.e. passive login) you create a new crazy long id for their creds. So, each time the user logs in passively, the crazy long id gets regenerated.
Question 145
For example, I have Level 1 (Restaurants, shopping, etc), level 2 (McDonalds, Burger King, etc). Up to this point it works fine, if I click on McDonalds, I'm taken to the main page.
Is the problem in the html, CSS, the jQTouch javascript? I'm using the Kilo example as a starting point. It's really just a series of lists, so I'm not sure where I'm going wrong. I know basic html and CSS, but I'm completely new at javascript.
Question 146
I have a question about date formats which doesn't appear to be covered in your PHP book or the FMI documentation.
It appears that the date formats for date fields when using the PHP API is in the US format of MM/DD/YYYY, but there doesn't appear to be any documentation around this.
I need to change my php pages so that the date fields appear in the Australian date format of DD/MM/YYYY when displayed and when entered via the web. Do you have any suggestions on how this can be done?
Kind regards,
Steve
Answer
That said, I have some suggestions. If you are just trying to change the display of dates for your web users, you can transform the date value retrieved from FileMaker using PHP's date() function. There are a million options for this function that you can read about here:
http://us.php.net/manual/en/function.date.php
If you are getting errors writing dd/mm/yyyy to the FileMaker, you can use the same date() function to convert any web data entry to the format appropriate for the database.
HTH,
j
Question 147
Question 148
FM Web Publishing - - wpc1 Web Scripting Error: 4, File: "Contacts", Script: "On Close Script", Script Step: "Adjust Window"
I'm familiar with scripts and which script steps are compatible with Web Publishing. However I'm not clear about when either the OnOpen or OnClose scripts that you can set in FileMaker Pro via the File menu > File Options > Open/Close tab are performed with PHP API clients? It appears that my OnClose script is being performed but I haven't setup any script calls in my PHP pages - I know the "Adjust Window" script step is not web publishing compatible, but I didn't realise this script was being performed by the Web Publishing Engine.
My OnOpen script also uses this same incompatible script step but there are no references to this in the logs. Do you know when/how often the OnOpen and OnClose script steps are being performed as far as Web Publishing via PHP is concerned?
Thanks,
Steve
Question 149
Question 150
I have found this (using $cgi->get('userName')) very handy as it allows me instant access to the username of the person signed in. Is there a way to set other variables such as "companyName" for easy retrieval in any page like I can for UserName?
Question 151
I have a database with a valuelist with the following values:
Sim
Não
[this is yes and no in Portuguese]. I'm displaying this valueist as a radio button on an input form, however there is a problem with the Não which appears in the web browser as "NNão" (i.e. there is an extra N at the beginning). The php page is saved as Unicode UTF 8 and other static text on the page also has "Não" which appears correctly. If I view the html source the radio button code appears as:
Code:.
<input type="radio" name="Question1" value="Sim" validate = "required:true " class = "radioClick">Sim
<input type="radio" name="Question1" value="NNão" validate = "required:true " class = "radioClick">NNão.
The php code for the input field is:
Code:.
<?php
foreach($yesnos as $yesno) {
$selected = "";
if( $yesno == $record->getField('Question1') ){
$selected = " checked=\"checked\"";
}
$yesno = htmlspecialchars($yesno);
?>
<input type="radio" name="Question1" value="<?php echo $yesno; ?>"<?php echo $selected; ?> validate = "required:true " class = "radioClick"><?php echo $yesno; ?>
<?php
}
?>.
Question 152
is it possible to Get(ScriptResult) to my php application?
Question 153
I have used PHP Site Assistant to generate a site for a simple purchase request database and
I'm trying to write a script within the confirmation.php page to trigger an email script to send the requested information record to me. But though the script runs, it keeps sending out a random record instead of the one just generated by the user.
Here is the newPerformScript I've added...
// Run script
$newPerformScript =& $fm->newPerformScriptCommand('requestForm', 'EmailTrigger'); $result = $newPerformScript->execute();
Is there anything else that needs to be added for the script to run properly? I can send you the complete page, if that helps.
Thanks a lot
shryn