No tuples available at this result index

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jan 10, 2018 3:11 pm

Wed Jan 10, 2018 3:27 pm

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.

Post Reply