February 9, 200620 yr 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?
February 9, 200620 yr Do you have a field, in your database, called "Account_Type" on the Layout "layout"? Garry
February 13, 200620 yr Author 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.
February 14, 200620 yr Author 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, 200620 yr by Guest
February 15, 200620 yr 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
February 16, 200620 yr 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!
February 16, 200620 yr oops it's echo <"hr"> while ( $FM->getNextRecord() ) { echo $FM->getField("Account_Desc") . " "; echo $FM->getField("Account_Type") . " "; echo <"hr">; }
February 16, 200620 yr 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.
February 21, 200620 yr Author 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
February 23, 200619 yr 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?
March 2, 200619 yr Author 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
Create an account or sign in to comment