php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48301 odbc_fetch_array() return error
Submitted: 2009-05-16 10:34 UTC Modified: 2015-04-11 14:35 UTC
Votes:16
Avg. Score:4.8 ± 0.6
Reproduced:15 of 15 (100.0%)
Same Version:14 (93.3%)
Same OS:13 (86.7%)
From: rmbaba at gmail dot com Assigned: cmb (profile)
Status: Closed Package: ODBC related
PHP Version: 5.2CVS-2009-05-16 (CVS) OS: ubuntu 9.4
Private report: No CVE-ID: None
 [2009-05-16 10:34 UTC] rmbaba at gmail dot com
Description:
------------
Hello,

I just prepared the server, installed apache, php5 mysql and odbc, I configured the the required files as well , and here is the result when I trying to connect to MS Access database:

+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from table;
lablablab...

Here is a small php code:

$conn = odbc_connect("DSN","",""); $select = "SELECT * FROM TABLE"; $result = odbc_exec($conn, $select); while ($row = odbc_fetch_array($result)) { $rowid = $row['name1']; $pwd = $row['password']; } echo "Row id :".$rowid; echo "password : ".$pwd;


The problem is, when I browse the file it as me to download it instead of explorer it, although the other projects with php and mysql are working well.

Reproduce code:
---------------
Here another small code after the tracing:

$db = odbc_connect("LOIR","","",SQL_CUR_USE_ODBC);
if (!$db) {
  die('ERROR: Cannot connect!');
}

$sql = "SELECT * FROM st_student";
$result = odbc_exec($db, $sql) or die('ERROR: Cannot execute query!');
if (!$result)
{
    exit("Error in SQL: ".$sql);
}

until now everything is okay unless this while array:

while (odbc_fetch_array($result))
{
 echo odbc_result($result,"name1");
}
odbc_close($db);

Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples available at this result index in /var/www/access.php on line 14

Although when I replace the above fetch array with this:

$row = odbc_fetch_array($result);
echo $row["name1"];
odbc_close($db);

it return one row and when field.

Expected result:
----------------
It supposed to return all 300 records in the database.

Actual result:
--------------
I don't have backtrace..

and I would appreciate your cooperation with this matter, because I'm tired now from it, since 4 days and I'm googling but no result.

Cordially,

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-17 04:43 UTC] Eric at juhaynum dot com dot br
Hi I'm getting the same error, it ask me to download the file..
 [2009-06-06 12:52 UTC] rmbaba at gmail dot com
SO any updates about this bug please?
 [2015-04-11 14:35 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-04-11 14:35 UTC] cmb@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC