brianread

ODBC link to filemaker DB from PHP, SQL select not being obeyed as expected (fixed)

Discussion created by brianread on Oct 15, 2012

HI

 

I am connecting to a flemaker 12 (client) uysing odbc from php 5.3 under Windows XP (up to date).

 

Here is the program I am using:

 

echo "Connecting to ODBC filemaker...";

$db = odbc_connect("filemaker-MES","Admin","xxxxxx") or die ("ODBC connection to filemaker failed");

$res = odbc_tables($db) or die("ODBC - tables - failed");

while (odbc_fetch_row($res)){

if(odbc_result($res,"TABLE_TYPE")=="TABLE")

echo" ".odbc_result($res,"TABLE_NAME");

 

}

 

$res = odbc_exec($db,"SELECT * FROM Meditators") or die("Filemaker SQL failed");

$rowNum = odbc_num_rows($res);

echo " Number of rows:".$rowNum." ";

while ($row = odbc_fetch_row($res)){

echo $row[0].$row[1];

}

 

Very simple

 

The output is as follows:

 

Connecting to ODBC filemaker...

Centres

Country

Emails

Meditators

NoEmailReason

NoMailReason

Occupation

TMStatus

TMStatus 2

Number of rows:-1

 

As you can see the SQL comes back with -1 Rows, whereas the actual table has 9,000+ records.

 

any ideas?

 

Cheers

 

Brian

 

PS Found the error - "$row = odbc_fetch_row" should be "$row = odbc_fetch_array".

 

Message was edited by: brianread

Outcomes