Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2006
    Posts
    3

    Question Unanswered: How does one establish a data connection using either Perl or PHP

    I am working on a project that involves the establishment of an Open Database Connection (ODBC) through the use of the Pervasive.SQL driver for the very first time, and have not been successful on figuring out on my own exactly how to even establish the connection and have not received adequate support from others that are involved with this project.

    Could someone provide me with a simple example of how that line of connection coding should appear when programmed by either using Perl (which I am more comfortable with) or PHP? The connection will be between a Linux-based website server and my client's Pinnacle DB server through a restricted port.

    Thank you in advance to whomever is able to assist.

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Here's a very simple PHP page that connects through ODBC:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>PHP Sample</TITLE>
    </HEAD>
    <BODY>
    <?php
    $conn=odbc_connect("DEMODATA","","",""); 
    $sql="select * from class";
    $rs=odbc_exec($conn,$sql);  
    echo "<table border=1>\n";
    $numfields = odbc_num_fields($rs);
    for($i=1;$i<=$numfields;$i++){
    	$fn=odbc_field_name($rs,$i);
    	echo "<th>$fn</th>";
    }
    echo "\n";
    while(odbc_fetch_row($rs)){ 
    	echo "<tr>\n";
    	for($i=1;$i<=$numfields;$i++){
    	   $fv=odbc_result($rs,$i);
    	   echo "<td>$fv</td>";
    	}   
    	echo "</tr>\n";
    } 
    echo "</table>\n";
    echo "<p>Number of Fields: $numfields</p>\n";
    ?>
    </BODY>
    </HTML>
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Jun 2006
    Posts
    3
    I uploaded the PHP coding to the website's server and tested it, but only the text, "Number of Fields:" appears. Nothing else. This should work as is and no alterations are needed, correct? If so, would this be an indication that the Pervasive client was not properly installed on the server?

  4. #4
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Well, you will need to change a little:
    Code:
    $conn=odbc_connect("DEMODATA","","",""); 
    $sql="select * from class";
    The "DEMODATA" is the name of the ODBC DSN and the "select * from class" is the SQL statement. I don't have a Linux box handy but I know the code works correctly on Windows.
    The code not working could indicate a problem with the Pervasive client. What version do you have installed?
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  5. #5
    Join Date
    Jun 2006
    Posts
    3
    Version 8 of the Pervasive client is what is being used. Another party was responsible for the installation, but mentioned they have never done this for a Linux-based system before. I have a deep, gut-wrenching feeling that something was not correctly done, and therefore continuing attempts of figuring out how to use it will be pointless.

    Do you know of a most efficient means in which to check and insure that the Pervasive installation has been done correctly?

  6. #6
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    The best way to tell is to try to connect to the server using one of the tools like BUTIL or ODBCTEST.
    You mentioned that the PHP isn't working. What's the behavior?
    I would suggest making sure the V8 client and server are updated. The current version is PSQL v8.7 SP3. Also, V8 support from Pervasive is going away in December so you may want to consider V9.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •