From:             andrewz at springsrescuemission dot org
Operating system: Linux 2.4.30 (Trustix 2.2)
PHP version:      5.0.4
PHP Bug Type:     dBase related
Bug description:  dbase functions return garabe on certain file

Description:
------------
Using PHP's dbase system cannot understand some columns and yields garbage
on a certain .dbf file (http://65.108.181.103/zip.dbf).  

The .dbf was tested successfully with several other programs
(OpenOffice.org 1.1.4 and Shapefile Library C).

According to file, .dbf is dbase 3 format:
$ file zip.dbf
zip.dbf: DBase 3 data file (586 records)

To enable dbase support, I used the standard Trustix 2.2 source RPM and
included "--enable-dbase".

On a different system with PHP 4.3.10 and Linux 2.4.27 (Redhat 7.3), I
verified the problem with dbase_get_record_with_names().  (The function
dbase_get_header_info() was not available on this platform.)

Reproduce code:
---------------
$db = dbase_open("zip.dbf",0);

print_r(dbase_get_header_info($db));

if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($db, $i);
        print_r($row);
  }
}



Expected result:
----------------
The dbase_header_info() does not understand some columns and includes
garbage (e.g. length field).  Then the dbase_get_record_with_names() has
incorrect data.  

Here is output of Shapefile Library C's dbfdump -h on the same zip.dbf. 
This output is good.

Field 0: Type=Double, Title=`AREA', Width=20, Decimals=5
Field 1: Type=Double, Title=`PERIMETER', Width=20, Decimals=5
Field 2: Type=Integer, Title=`ZT08_D00_', Width=11, Decimals=0
Field 3: Type=Integer, Title=`ZT08_D00_I', Width=11, Decimals=0
Field 4: Type=String, Title=`ZCTA', Width=5, Decimals=0
Field 5: Type=String, Title=`NAME', Width=90, Decimals=0
Field 6: Type=String, Title=`LSAD', Width=2, Decimals=0
Field 7: Type=String, Title=`LSAD_TRANS', Width=50, Decimals=0
                AREA            PERIMETER   ZT08_D00_  ZT08_D00_I ZCTA 
NAME                                                                      
                LSAD LSAD_TRANS
             0.05115              1.30727           2           1 80428
80428                                                                     
                Z5   5-Digit ZCTA


Actual result:
--------------
SCRIPT OUTPUT 

Array
(
    [0] => Array
        (
            [name] => AREA
            [type] => unknown
            [length] => 1300
            [precision] => 0
            [format] => ´       "@
            [offset] => 1
        )

    [1] => Array
        (
            [name] => PERIMETER
            [type] => unknown
            [length] => 1300
            [precision] => 0
            [format] => ´       "@
            [offset] => 1301
        )


[truncated]

-- 
Edit bug report at http://bugs.php.net/?id=33285&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33285&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33285&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33285&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33285&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33285&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33285&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33285&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33285&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33285&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33285&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33285&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33285&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33285&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33285&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33285&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33285&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33285&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33285&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33285&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33285&r=mysqlcfg

Reply via email to