After I connect and execute my SQL string, I try to use the "odbc_num_rows" function to retrieve the number of records, like the following:
$link = odbc_connect ("search2","sa","password",SQL_CUR_USE_IF_NEEDED ) ;
$res = odbc_exec ($link,$sqlstring);
$nrows = odbc_num_rows ($res ) ;
The "odbc_num_rows" function always returns a value of -1, even though the $res recordset actually does have records. If I loop through the recordset (using a hard-coded upper limit since I do not know the number of records) the program does write out the field values for each record. However, since I hard-code the upper limit once the program writes out all of the records it continues to write out the values for the last record over and over again until the number of rows in the table is equal to the upper limit of my loop.
I actually found a note on the "PHP Manual" site that said:
"Using odbc_num_rows() to determine the number of rows available after a SELECT will return -1 with many drivers"
But it did not provide any solutions or suggestions.
What can I do to get this function to work properly? Are there any other ways to do it? What driver do I need; where do I get it and how do I implement it?
$link = odbc_connect ("search2","sa","password",SQL_CUR_USE_IF_NEEDED ) ;
$res = odbc_exec ($link,$sqlstring);
$nrows = odbc_num_rows ($res ) ;
The "odbc_num_rows" function always returns a value of -1, even though the $res recordset actually does have records. If I loop through the recordset (using a hard-coded upper limit since I do not know the number of records) the program does write out the field values for each record. However, since I hard-code the upper limit once the program writes out all of the records it continues to write out the values for the last record over and over again until the number of rows in the table is equal to the upper limit of my loop.
I actually found a note on the "PHP Manual" site that said:
"Using odbc_num_rows() to determine the number of rows available after a SELECT will return -1 with many drivers"
But it did not provide any solutions or suggestions.
What can I do to get this function to work properly? Are there any other ways to do it? What driver do I need; where do I get it and how do I implement it?