Problem with DBase parse. (.dbf)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nickelnick
Forum Newbie
Posts: 6
Joined: Thu Jan 17, 2008 2:26 pm

Problem with DBase parse. (.dbf)

Post by nickelnick »

heres the code I have, and still i am unable to return any values from this dbf.

Code: Select all

<?php
dbase_open('MNU.DBF', 2) or die ("Failed to open DBF");
if ($dbase_open) {
  $record_numbers = dbase_numrecords($dbase_open);
  for ($i = 1; $i <= $record_numbers; $i++) {
      // do something here, for each record
echo $record_numbers['SHORTNAME'];
  }
} 
?>
Attachments
MNU.ZIP
Rename from to ZIP From DBF.
THIS FILE is supposed to be DBase IV
(10.17 KiB) Downloaded 14 times
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

Re: Problem with DBase parse. (.dbf)

Post by bouncer »

are you giving the right path to your .dbf file ?

try use full path like this, and use this instead:

Code: Select all

 
$dbase = dbase_open('fullpath\MNU.dbf', 2) or die (error());
if ( $dbase ) {
    $record_numbers = dbase_numrecords( $dbase );
 
    for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($dbase, $i);
        echo $row['field_name'];
    }
}
dbase_close( $dbase );
 
regards
nickelnick
Forum Newbie
Posts: 6
Joined: Thu Jan 17, 2008 2:26 pm

Re: Problem with DBase parse. (.dbf)

Post by nickelnick »

if i my root dir when i log in is httpdocs, does that mean i should put 'httpdocs\db\EMP.DBF', '\httpdocs\db\EMP.DBF'

or

db\EMP.DBF (or)
\db\EMP.DBF
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

Re: Problem with DBase parse. (.dbf)

Post by bouncer »

if your script is in the same root as your .dbf files you can avoid full path if not use the full path, i'm not sure about this. :roll:

regards
nickelnick
Forum Newbie
Posts: 6
Joined: Thu Jan 17, 2008 2:26 pm

Re: Problem with DBase parse. (.dbf)

Post by nickelnick »

bouncer wrote:if your script is in the same root as your .dbf files you can avoid full path if not use the full path, i'm not sure about this. :roll:

regards
thats what i figured. is my database somehow not db4 even though it specifies on the file that it is?
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

Re: Problem with DBase parse. (.dbf)

Post by bouncer »

have you tried to use the script in the #2 thread ?

regards
Post Reply