fmwebschool.com
Top Experts [learn more]Top 4-10
webko

9743 K
bandmandq

2458 K
Genx

1525 K
4. tcmeyers
5. kbata
6. Martie
7. Hammerton
8. rrenfrow
9. bneeman
10. plegler
Welcome, Guest. Please login or register.
June 19, 2013, 10:04:56 PM

Login with username, password and session length
Search:     Advanced search
Welcome to the FileMaker Web Masters Exchange.  If you have any questions about how to use this forum, please watch the getting started movie at:
http://www.fmwebschool.com/movies/forum1/forum1.html
27508 Posts in 6074 Topics by 1524 Members
Latest Member: fmwebster
* Home Help Search Calendar Login Register
+  fmwebschool.com
|-+  PHP Web Publishing Technologies
| |-+  FileMaker's New PHP API
| | |-+  getRecords error
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: getRecords error  (Read 1521 times)
cuitw
Jr. Member
**
Offline Offline

Posts: 34



WWW
« on: April 19, 2011, 08:58:19 PM »

I have yet another question that I can't seem to figure out the reason/cause.

In a php file I simply created the following codes:

Quote
<?php
session_start();
define('FM_HOST', '**Hidden**');
define('FM_FILE', '**Hidden**');
define('FM_USER', '**Hidden**');
define('FM_PASS', '**Hidden**');
ini_set("include_path", ".:/Library/WebServer/Documents/");
include ('FileMaker.php');
require_once('FileMaker.php');
error_reporting(0);
ini_set('display_errors', '0');
$ttstemp = $_POST['prefix'].'-'.$_POST['noyear'].$_POST['nomonth'];
$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
if (isset($_SESSION['record']) && $_SESSION['record'] !="") {
  $request = $fm->newAddCommand('form_api');
  $request->setField('no_ref', $ttstemp );
  $request->setField('PO', $_POST['po']);
  $result = $request->execute();
  $records = $result->getRecords();
  $found = $result->getFoundSetCount();
  $_SESSION['ent'] = $records[0]->getRecordId();

For some reasons if I disable the line "$request->setField('no_ref', $ttstemp );" it works perfectly but if I remove the comment and let it run it returns the following error:

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

line 66 is $records = $result->getRecords();

I have no idea what is happening... What is so wrong about "$request->setField('no_ref', $ttstemp );"............
Logged
webko
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2060
Kudos: 9743



WWW
Applications:
« Reply #1 on: April 19, 2011, 11:21:58 PM »

Well, first of all, I'd try reflecting back $ttstemp to see that it's properly populated

I think the use of single quotes might cause an issue, but I'm not sure...

Code:
$ttstemp = $_POST['prefix'].'-'.$_POST['noyear'].$_POST['nomonth'];
echo $ttstemp;

I'd write it like this, but that's only habit rather than anything I can really think of...

Code:

$ttstemp = $_POST['prefix']."-".$_POST['noyear'].$_POST['nomonth'];
echo $ttstemp;
Logged

tim.webko_at_gmail.com
cuitw
Jr. Member
**
Offline Offline

Posts: 34



WWW
« Reply #2 on: April 19, 2011, 11:53:33 PM »

Thank you for your response, webko. Your are helpful as always!

I changed the single quotes but it is still the same.

The data echoed is exactly what I wanted. FYI it is something like AK-1108.
Logged
cuitw
Jr. Member
**
Offline Offline

Posts: 34



WWW
« Reply #3 on: April 19, 2011, 11:59:51 PM »

hmmm... there is a field that uses the field no_ref for an autoenter calculation. Do you think this would pose any problem?
Logged
webko
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2060
Kudos: 9743



WWW
Applications:
« Reply #4 on: April 20, 2011, 12:12:18 AM »

I don't use the API, but aren't you asking for a Add, but doing a Find?
Logged

tim.webko_at_gmail.com
cuitw
Jr. Member
**
Offline Offline

Posts: 34



WWW
« Reply #5 on: April 20, 2011, 12:13:47 AM »

Actually no, if I disable this line the script works just fine. It create records and enter data as expected. I just do not know why if I let this line run it ruins the whole script...
Logged
cuitw
Jr. Member
**
Offline Offline

Posts: 34



WWW
« Reply #6 on: April 20, 2011, 01:05:46 AM »

I have given up. Now I just removed the line and use a newEditCommand to set the field AFTER the record is created. It works fine now. Thanks again for your help! Wink
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!