|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31750 pg_fetch_array fails if PGSQL_ASSOC is specified
Submitted: 2005-01-29 09:29 UTC Modified: 2005-02-15 00:15 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mancini at nextcode dot org Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 5.0.3 OS: windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mancini at nextcode dot org
New email:
PHP Version: OS:


 [2005-01-29 09:29 UTC] mancini at nextcode dot org
Tested with original php_pgsql 7.4 binary distribution on php 5.0.3 distribution

The function fails every time if PGSQL_ASSOC is specified to pg_fetch_array 

It works fine if that is not specified , and pg_fetch_assoc()  works too btw , furthermore mysql_fetch_assoc() with MYSQL_ASSOC works too

And quite disturbing looking for the error message on google
gives about 2,620 results of pages experiencing it

Reproduce code:
$query = "SELECT usename,passwd,usesuper FROM pg_user";
$result = pg_query($query);
while ($line = pg_fetch_array($result,PGSQL_ASSOC)){
    echo $line['usename'];

Expected result:

Actual result:
PHP Warning:  pg_fetch_array() Unable to jump to row 1 on PostgreSQL result index 4 in C:\apache2triad\htdocs\test.pgsql.php on line 4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-29 20:34 UTC]
Can't reproduce with 5.0.3 & PG 7.3.6 under Linux.
Please provide more info.
 [2005-01-30 03:55 UTC] mancini at nextcode dot org
The PostgreSQL version i am running is 8.0.0 windows oficial binary release

here is the VERSION() output
PostgreSQL 8.0.0 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)
 [2005-02-15 00:15 UTC]
You have to specify the row number if you want to specify the third argument. In order to have "empty" second argument pass NULL so the correct code becomes:

while ($line = pg_fetch_array($result, NULL, PGSQL_ASSOC))

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 22:01:30 2024 UTC