Page 1 of 1

No tuples available at this result index

Posted: Wed Jan 10, 2018 3:27 pm
by qubit
I have this simple test page where I am querying an Access MDB:

try {
$conn = odbc_connect("databasename", "", "");
$sql = "SELECT CustomerID, CompanyName FROM Customers";
$result = odbc_exec($conn,$sql);
while ($row = odbc_fetch_array($result)){
echo $row["CustomerID"].' '.$row["CompanyName"].'</br>' ;

} catch (Exception $e) {
echo $e->getMessage(), "\n";
..which returns results but they are unsorted.

When I change the $sql to: "SELECT CustomerID, CompanyName FROM Customers ORDER BY CompanyName", I receive the following error: "odbc_fetch_array(): No tuples available at this result index..."
I have been searching the web and find reference to "odbc_next_result()", but that does not seem to help at all.
I have tried "odbc_fetch_row" - same error.

Update: It works properly when I add a WHERE clause to select certain records. /q

Why would applying a sort produce this error?
Any help would be appreciated.