Reading a Paradox DB Under Windows using XAMPP

Written by James McDonald

April 15, 2008

Update: New versions of XAMPP for Windows don’t have the PHP paradox module. The latest I could find that contained the necessary php/ext/php_paradox.dll file was XAMPP for Windows 1.7.0

Windows (XP) provides a Paradox Driver that when used with Access can read a *.db file by either linking or importing the table. However I found that when using ADODB and VB Script to connect to the Paradox DB a time field came out as 12:00 AM. I Googled and tried all sorts of things to get the raw milliseconds-from-midnight out of the db and not the erroneous 12:00 AM but found no solution.

I thought perhaps I could use Perl but Google was strangely silent regarding both the pro’s and con’s.

PHP has an interface to the Paradox Library methods. I tried to download PHP on it’s own and then install pxlib using pear install paradox and pecl install paradox but they all failed aswell.

Enter XAMPP. This is a easy to install bundle of MySQL, PHP, APACHE etc. Where it comes in handy for me is that it has a heap of sample scripts showing how to connect to a paradox database, query it’s properties and also export an Excel spreadsheet to a browser.

After installing XAMPP Windows 1.6.6a or XAMPP for Windows 1.7 and spending a half day hacking on the included sample scripts and learning a few tricks from the documentation. I have a PHP based query form which then passes it’s values to a PHP paradox script which in turn reads the database and returns a nicely formatted Excel spreadsheet to the calling browser.

A word of warning don’t download the WAMPP 2.2 package as I did as it doesn’t have Paradox support. It looks like paradox support was removed in 2009.

How to Check if your version of PHP has Paradox Support

create a php file “info.php” somewhere in your webroot




Access it via your browser http://yourwebserver/info.php

You know you have Paradox support if you see a section similar to this


I did all this on Windows XP Pro SP2.

The form used to submit data to the PHP / Paradox script

You don’t use SELECT * to query using the paradox db methods…
When using the php methods you need to loop through the entire table.
such as …

    // path to your db
    $trandb = "C:/path/to/yourdb/dbname.db";
    // check to make sure you can create a paradox object
    // exit if not

    if(!$pxdoc = px_new()) {
        exit("Unable to create a px_new object");
        /* Error handling */
    // open the paradox database using fopen and return a file pointer
    // "r" means readonly
    $fp = fopen($trandb, "r") or exit("Cannot open $trandb");

    // now use paradox method to open the file
    // pointer and assign it to the pxdoc object
    if(!px_open_fp($pxdoc, $fp)) {
        exit("px_open_fp error");
            /* Error handling */
    // grab some information from the paradox db
    // $myArray = px_get_info($pxdoc);
    // if you want to print details about the db use 
    // this commented code
    // echo "DB Info: preformattag";
    // print_r($myArray);
    // echo "End DB Info. endpreformattag" ;
    // This code would write the entire db to screen
    // reset ($myArray);
    // while (list($key, $val) = each($myArray)) {
           // echo "$key =--> $val\n 
    // }
    // do a check for the number of records in the db
    $int = px_numrecords($pxdoc);

    //reset my record to nothing
    $myRecord = "";

    // I'm looping back through the db from newest to oldest 
    // hence the $i--
    for ($i = $int - 1 ; $i > 0; $i--) {
        // get each record in turn
        $myRecord = px_get_record($pxdoc, $i) ;
        //reset the array back to it's first element
        reset ($myRecord);
        //grab the transaction date from the record 
        // so we can compare it to our constraints
        $record_date = 
            px_date2string ($pxdoc, $myRecord["TranDate"],"Y-m-d")
        if (( $record_date &gt;= $fromdate ) 
        and ( $record_date &lt;= $todate)) {
            // now we populate the $fields array 
            // with the correct values converting
            // them if necessary
            $fields[0] = $myRecord["Customer"];
            $fields[1] = $myRecord["CustName"];
            $fields[2] = $myRecord["Vehicle"];
            $fields[3] = $myRecord["Item"];
            $fields[4] = $myRecord["Docket"];
            $fields[5] = px_date2string  (
                $pxdoc, $myRecord["TranDate"], "d/m/Y"
            $fields[6] = px_timestamp2string( 
                $pxdoc, $myRecord["TranTime"], "h:i:sA"
            $fields[7] = $myRecord["Order"];
            $fields[8] = $myRecord["Source"];
            $fields[9] = $myRecord["SourceName"];
            $fields[10] = $myRecord["Destination"];
            $fields[11] = $myRecord["DestName"];
            $fields[12] = $myRecord["Net"];
            $fields[13] = $myRecord["CancelledDocket"];

            //set the pointer back to the first element of the array


            while (list($key, $val) = each($fields)) {
                //when writing to screen you 
                //can use this for creating tabs
                //tab is "\t"
                echo "
$key: $val";

    //Close the pxlib objects



    //Close the actual file


    //not sure what this exit does but 
    // it was used in the excel writer code
    // so I include it here also


  1. Anata

    Could you explain more detail how to “hacking on the included sample scripts and learning a few tricks from the documentation”. Or could you upload that script. Thank before and after. I’m so confused

  2. james

    Once you have installed XAMPP the included sample scripts are located in
    :\xampp\htdocs\xampp\special\paradox\. They show how to connect and query the paradox db.

    You connect to the XAMPP installation via a webbrowser (http://ip_of_xampp_server) and there are links to all the different examples

  3. danai

    Now I can connect to Paradox. But i don’t know how to query the Paradox table such as “SELECT * FROM tblUser”. I try to find the way in but I found only the Paradox function.

    Could you give me the sample code of this method?


  4. Rommel Epino

    Have you tried query the paradox using select? any way in or do you have sample code

  5. harisrozak

    GREAT!,Thx so much!

  6. Anil Sharma

    I read your article and installed xampp. First, tried with 1.7.7 and then with 1.6.6. In both cases, I could not find the paradox.dll, i.e., paradox driver was not installed. What could I be doing wrong? Is it possible to email me a copy a copy of php_paradox.dll.

    • admin

      When I look into my \xampp\readme_en.txt file I have this version “###### ApacheFriends XAMPP (Basispaket) version 1.7.0 ######”

      If you have a look under \xampp\php\ext it should be there.

      You may also have to uncomment the extension=php_paradox.dll in xampp\php\php.ini

      My php.ini extension section looks as follows:

      ; Dynamic Extensions ;
      ; If you wish to have an extension loaded automatically, use the following
      ; syntax:
      ;   extension=modulename.extension
      ; For example, on Windows:
      ;   extension=msql.dll
      ; ... or under UNIX:
      ; Note that it should be the name of the module only; no directory information
      ; needs to go here.  Specify the location of the extension with the
      ; extension_dir directive above.
      ; Windows Extensions
      ; Note that ODBC support is built in, so no dll is needed for it.
      ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
      ; extension folders as well as the separate PECL DLL download (PHP 5).
      ; Be sure to appropriately set the extension_dir directive.
      ;extension=php_yaz.dll ; Module make problems


  1. Updating a Paradox DB using PHP and the Paradox Extension | The Southern IT Observer - […] Reading a Paradox DB Under Windows using XAMPP […]

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

PC Build

I recently built myself a PC using the SilverStone SG13 Case. I am planning to use it as a Hot Spare. So any client...