Jump to content

This topic is 6910 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

Posted (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 by Guest
Posted

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!

Posted

oops it's echo <"hr">

while ( $FM->getNextRecord() ) {

echo $FM->getField("Account_Desc") . "

";

echo $FM->getField("Account_Type") . "

";

echo <"hr">;

}

Posted

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.

Posted

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

Posted

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?

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.