p_squared Posted February 9, 2006 Posted February 9, 2006 Hi everyone, I have recently started working FM-and-PHP, but I am having some issues. I want to be able to display the contents of my table using: <?php include("fmandphp/fmandphp.php"); $FM = new FM_and_PHP(); $FM->setFileMakerHost("localhost","80","7"); $FM->setDatabaseName("database"); $FM->setDatabaseLayout("layout"); $FM->setDatabaseUserPassword("user","pass"); $FM->setCommand("findall"); $FM->doQuery(); if ( $FM->getErrorNumber() != 0 ) { echo "The following error occurred: "; echo "[b]" . $FM->getErrorDescription() . "[/b]"; die(); } echo "Number of records: " . $FM->getFoundCount() . " "; while ( $FM->getNextRecord() ) { echo $FM->getField("Account_Desc") . " "; echo $FM->getField("Account_Type") . " "; } Using the supplied test database, this code works correctly... it outputs the first 10 records of the table. When I use my database, only 1 record is displayed, and only the first field (Account_Desc) is displayed. When the script tries to display the second field, I get the following: Notice: Undefined index: Account_Type in c:Inetpubwwwrootfmandphpfmandphp.php on line 561 I am able to use the next/previous functions. If I go to the 2nd page of results, it outputs the 11th record. Anyone have any suggestions?
Garry Claridge Posted February 9, 2006 Posted February 9, 2006 Do you have a field, in your database, called "Account_Type" on the Layout "layout"? Garry
p_squared Posted February 13, 2006 Author Posted February 13, 2006 Yes, the field is there. This problem occurs for about half of the fields that I try. I cannot find a reason why some work, and some do not.
p_squared Posted February 14, 2006 Author Posted February 14, 2006 (edited) When I loop through all the columns using the getColumn() command, I get gaps where there is no column name. If I try to print a field that is located after the first gap, I get the undefined index error. If the field appears before the first gap, it works. Anybody run into anything like this before? Peter UPDATE: I have just realized that the fields that cannot be displayed with getColumns() have two colons in the field name (:. I believe that this represents relationships. Is it possible to work with relationships in FM-and-PHP? Edited February 14, 2006 by Guest
Garry Claridge Posted February 15, 2006 Posted February 15, 2006 I don't know about FM-and-PHP, however you maybe able to work with it if you name the fields with the "::". Good Luck. Garry
nmb Posted February 16, 2006 Posted February 16, 2006 I think that you need to add this line: echo "hr"; at the end. whole code: while ( $FM->getNextRecord() ) { echo $FM->getField("Account_Desc") . " "; echo $FM->getField("Account_Type") . " "; echo "hr"; } By the way, I am a beginner at this FMandPHP, too (but I can read German). Tell me if this works! Thanks!
nmb Posted February 16, 2006 Posted February 16, 2006 oops it's echo <"hr"> while ( $FM->getNextRecord() ) { echo $FM->getField("Account_Desc") . " "; echo $FM->getField("Account_Type") . " "; echo <"hr">; }
nmb Posted February 16, 2006 Posted February 16, 2006 come to think of it... I don't know why that solves the problem. I can recreate your problem, though, if I leave the horizontal rule out.
p_squared Posted February 21, 2006 Author Posted February 21, 2006 Hi nmb, I tried this out, but I have get the same problem if the is there or not. Garry, I don't think that I can rename the fields because the there are scripts already created that require these fieldnames. Do you know of any tutorials or examples using relationships with FM-and-PHP? Thanks, Peter
Singlequanta Posted February 23, 2006 Posted February 23, 2006 Howdy; I've just build a database with those parameters and used this script: <?php include("fmandphp/fmandphp.php"); $FM = new FM_and_PHP(); $FM->setFileMakerHost("localhost","80","7"); $FM->setDatabaseName("database"); $FM->setDatabaseLayout("layout"); $FM->setDatabaseUserPassword("user","pass"); $FM->setCommand("findall"); $FM->doQuery(); if ( $FM->getErrorNumber() != 0 ) { echo "The following error occurred: "; echo "" . $FM->getErrorDescription() . ""; die(); } echo "Number of records: " . $FM->getFoundCount() . " "; while ( $FM->getNextRecord() ) { echo $FM->getField("Account_Desc") . " "; echo $FM->getField("Account_Type") . " "; } It seems to work fine for me. Two questions... 1) Have you updated to the latest version of the server? (This is an absolute must) 2) can you copy and paste just line 561 of your code please?
p_squared Posted March 2, 2006 Author Posted March 2, 2006 Hi, I found out what was wrong. There were relationships to other database files, and those external files did not have a same username/password, or the fmxml priviledge. I am still getting the same type of error for any field that is of type "calculation". Does fm-and-php support working with these fields? Peter
Recommended Posts
This topic is 6910 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now