DBMaker Starting Guides

The Starting Guide for PHP

1. Installation

  1. Unpack the PHP package.
    $ tar zxvf php-4.0b2-dbmaker.tar.gz
    
  2. Configure the package.
    $ ./configure \
      --with-dbmaker=/home/dbmaker/3.5/ \
      --with-apxs=/usr/sbin/apxs \
      --enable-track-vars
    
  3. Build the package.
    $ make
    
  4. Stop the Apache server.
    $ /etc/rc.d/init.d/httpd stop   (RedHat 6)
    $ apachectrl stop               (Others)
    
  5. Install the package.
    $ make install
    
  6. Start the Apache server.
    $ /etc/rc.d/init.d/httpd start
    

2. Your First PHP Program

We will write a very simple PHP file to retrieve the data in the database test.

Write the following PHP code to a file, and name it with the extension name .php (like test01.php).


<html>
  <head>
    <title>My first PHP </title>
  </head>

  <body>
    <?
    // connect to the database.
    $con = odbc_connect('test', 'SYSADM', "");

    // get result handle
    $rs = odbc_exec($con, 'select * from t1');

    // fetch data
    while (odbc_fetch_row($rs)) {
      // get column data
      $c1 = odbc_result($rs, 1);
      $c2 = odbc_result($rs, 2);

      // print out the result
      echo "result --> c1 = $c1, c2 = $c2<br>";
      }

    // close the result
    odbc_free_result($rs);

    // close the connection
    odbc_close($con);
    ?>
  </body>
</html>

For the detailed information of these PHP functions, please reference the PHP Manual (in php-manual.tgz).

3. Testing You First PHP Program

  1. Put the PHP program to the document directory of your Apache server (like '/home/httpd/html').
    $ cp test01.php /home/httpd/html
    
  2. Copy the database configuration file dmconfig.ini from where the database created to the directory which the PHP file is.
    $ cp dmconfig.ini /home/httpd/html
    
  3. Browse the page by any browser.

4. More Information

The following are the PHP related information:

Sites

  1. PHP Home Site

Documents

  1. Notes for Slackware Linux
  2. DBMaker PHP Samples
  3. PHP3 + DBMaker Database Programming (in Chinese)
  4. Introductory Tutorial (from PHP home)

[ Back To Manuals Index ]

Copyright 2002 SYSCOM Computer Engineering Co. All rights reserved.