<?php

// PHP dBase test
$infotext = '<b><u>Demo: PHP dBase</u></b><br><br>';

// dbase setup

// database "definition"
$def = array(
  array("jtime",    "N", 10, 0),
  array("date",     "D"       ),
  array("name",     "C", 50   ),
  array("age",      "N",  3, 0),
  array("email",    "C", 64   ),
  array("ismember", "L"       )
);
// create database
$created = "no";
$created = @dbase_create('./dbase/test.dbf', $def);
if ( $created == FALSE) {
  echo "ERROR.<br>Can not create: <b>./dbase/test.dbf</b>\n";
  exit;
} else {
$infocreate = "dBase: ./dbase/test.dbf<br>was created<br><br>";
}

// Add some records
// open in read-write mode
$db=@dbase_open('./dbase/test.dbf', 2);
if($db){

  $jtime=time() -4317;
  @dbase_add_record($db, array(
      $jtime,
      date('Ymd', $jtime),
     'Maxim Topolov',
     '23',
     'max@example.com',
     'T'));

  $jtime=time() -2133;
  @dbase_add_record($db, array(
      $jtime,
      date('Ymd', $jtime),
     'halojoy',
     '67',
     'halojoy@hotmail.com',
     'T'));

  $jtime=time();
  @dbase_add_record($db, array(
      $jtime,
      date('Ymd', $jtime),
     'Bill Clinton',
     '83',
     'billyboy@nogoodservice.net',
     'T'));

}
@dbase_close($db);


// Display this Publically
echo "$infotext";
echo "$infocreate";

// Get all records and display them
// open in read-only mode
$db=@dbase_open('./dbase/test.dbf', 0);
if($db){
  $record_numbers = @dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
     $row = @dbase_get_record_with_names($db, $i);
     if ($row['ismember'] == 1) {
         $jdate = date( 'Y-m-d @ H:i:s', $row['jtime'] );
         echo "Member #$i: " . trim($row['name']) . "<br>.... Email: " . trim($row['email']);
         echo "<br>.... Joined: " . $jdate . "<br>.... Age: " . trim($row['age']) . "\n<br><br>";
     }
  }
@dbase_close($db);
}


// stop php script
exit;

?>

Quote http://php.net/dbase :
Return Values
Returns a database link identifier if the database is successfully created,
or FALSE if an error occurred.

My Question:
I can get no link identifier returned.
Only get these 3 different values:
1
2
FALSE

How do I get this 'link identifier' ?
From the dbase_create function. Manual: [man]dbase[/man]

thanks
halojoy - now an dBase AND flat file database man

🙂

    I'm assuming this is the part of the code you're talking about?

    $created = "no"; 
    $created = @dbase_create('./dbase/test.dbf', $def); 
    if ( $created == FALSE) { 
      echo "ERROR.<br>Can not create: <b>./dbase/test.dbf</b>\n"; 
      exit; 
    } else { 
    $infocreate = "dBase: ./dbase/test.dbf<br>was created<br><br>"; 
    } 

    I'm not entirely sure why you defined $created before you used it... shrug anyway, try re-working the code to something like this:

     
    if ( !@dbase_create('./dbase/test.dbf', $def) ) { 
      echo "ERROR.<br>Can not create: <b>./dbase/test.dbf</b>\n"; 
      exit; 
    } else { 
    $infocreate = "dBase: ./dbase/test.dbf<br>was created<br><br>"; 
    } 

    NOTE: I simply took this idea from Example 1 on the manual page for [man]dbase_create/man.

      thanks for response

      this dBase using php is much easier, and a good alternative to flat file data storage
      no MySQL select query problem problem -> I get a BIG headache :eek:

      now
      return value from
      php function

      [man]dbase_create[/man]

      is important only if I can test if was success or not
      in my thinking, it is enough to see if is FALSE or not

      Because, if success, I will have link to my database file created anyway
      I have already submitted it, as a parameter for function!

      created = @dbase_create('./dbase/test.dbf', $def); 

      I have tested this at my website.
      Runs without any problems,
      and puts out all (3) user records complete data.
      works as a charm.
      I only wanted make sure I know as much as possible, about php dbase functions and the proper use of them.

      THANKS for wanting to assist and help me,
      bradgrafelman

      <?php
      // database "definition" 
      $def = array( 
        array("jtime",    "N", 10, 0), 
        array("date",     "D"       ), 
        array("name",     "C", 50   ), 
        array("age",      "N",  3, 0), 
        array("email",    "C", 64   ), 
        array("ismember", "L"       ) 
      ); 
      // create database 
      $created = "no"; 
      $created = @dbase_create('./dbase/test.dbf', $def); 
      if ( $created == FALSE) { 
        echo "ERROR.<br>Can not create: <b>./dbase/test.dbf</b>\n"; 
        exit; 
      } else { 
      $infocreate = "dBase: ./dbase/test.dbf<br>was created<br><br>"; 
      }
      ?>
      created = @dbase_create('./dbase/test.dbf', $def); 
        Write a Reply...