php.net |  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
Votes:1
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
 [2005-01-29 09:29 UTC] mancini at nextcode dot org
Description:
------------
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
http://www.google.com/search?hl=en&lr=&q=%22Unable+to+jump+to+row+1+on+PostgreSQL+result+index%22
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:
----------------
pgsql

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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-29 20:34 UTC] tony2001@php.net
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] edink@php.net
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: Fri Jul 26 23:01:30 2024 UTC