php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #341 Creating incorrect .dbf format files
Submitted: 1998-05-03 23:01 UTC Modified: 1998-05-25 18:38 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: rgreene at pcpros dot net Assigned: jim (profile)
Status: Closed Package: dBase related
PHP Version: 3.0 Release Candidate 4 OS: Linux 2.0.30 (RH4.2)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rgreene at pcpros dot net
New email:
PHP Version: OS:

 

 [1998-05-03 23:01 UTC] rgreene at pcpros dot net
The following script doesn't create a properly formatted .dbf 
file according to MS Access and MS Foxpro.  There are no data
records; just the header.  This appears to be something with
the size being incorrect -- a table created from MS Foxpro
with the same number of fields was larger; again, no data.

Script is executed from the command line as:
    php -q <script-name

------------------------ BEGINNING OF CODE ----------------
<?
# General constants:
  $fn = "rep.dbf";
  $MAX_CD = 1;

# Define the dbase structure:
  $db_struct = array(
                        array( "cl_id", "n", 11, 0 ),
                        array( "cl_name", "c", 60 ),
                        array( "cl_address", "c", 100 ),
                        array( "cl_city", "c", 50 ),
                        array( "cl_state", "c", 50 ),
                        array( "cl_zip", "c", 50 ),
                        array( "cl_country", "c", 50 ),
                        array( "cl_phone", "c", 50 ),
                        array( "cl_email", "c", 50 ),
                        array( "cl_handle", "c", 50 ),
                        array( "cc_type", "c", 50 ),
                        array( "cc_number", "c", 50 ),
                        array( "cc_name", "c", 50 ),
                        array( "cc_expDate", "c", 50 ),
                        array( "sh_name", "c", 50 ),
                        array( "sh_address", "c", 100 ),
                        array( "sh_city", "c", 50 ),
                        array( "sh_state", "c", 50 ),
                        array( "sh_zip", "c", 50 ),
                        array( "sh_country", "c", 50 ),
                        array( "sh_phone", "c", 50 ),
                        array( "do_subtotal", "n", 20, 4 ),
                        array( "do_tax", "n", 20, 4 ),
                        array( "do_shipping", "n", 20, 4 ),
                        array( "im_subtotal", "n", 20, 4 ),
                        array( "im_tax", "n", 20, 4 ),
                        array( "im_shipping", "n", 20, 4 ),
                        array( "ord_status", "c", 15 ),
                        array( "label", "c", 4 ),
                        array( "number", "c", 10 ),
                        array( "artist", "c", 30 ),
                        array( "title", "c", 30 ),
                        array( "config", "c", 3 ),
                        array( "genre", "c", 10 ),
                        array( "type", "c", 4 ),
                        array( "type1", "c", 6 ),
                        array( "cost", "n", 8, 2 ),
                        array( "list", "n", 8, 2 ),
                        array( "sale", "n", 8, 2 ),
                        array( "rel_date", "d" ),
                        array( "spcl", "c", 1 ),
                        array( "upc", "c", 13 ),
                        array( "qty", "n", 11, 0 ),
                        array( "vendor", "c", 4 ),
                        array( "country", "c", 3 )
                     );

  echo "creating $fn\n";
  $id = dbase_create($fn, &$db_struct);
  echo "dbase has " . dbase_numfields($id) . " fields\n";

  echo "closing database...\n";
  dbase_close($id);

  echo "done.\n";
?>
----------------------- END OF CODE -------------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-05-25 18:38 UTC] jim
This was because some field names were too long (limit is apparently 10 characters). Added a check to the dbase_create() function to enforce this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 12:01:32 2025 UTC