If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > How does one establish a data connection using either Perl or PHP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-16-06, 10:40
RathmannDesign RathmannDesign is offline
Registered User
 
Join Date: Jun 2006
Posts: 3
Question 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.
Reply With Quote
  #2 (permalink)  
Old 06-16-06, 14:07
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #3 (permalink)  
Old 06-16-06, 14:38
RathmannDesign RathmannDesign is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 06-16-06, 15:25
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #5 (permalink)  
Old 06-20-06, 05:52
RathmannDesign RathmannDesign is offline
Registered User
 
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?
Reply With Quote
  #6 (permalink)  
Old 06-20-06, 08:48
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On