Did this article resolve your question/issue?


Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025



Sample PHP Programs to Access a Progress DB through ODBC


Article Number000001667
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: 10.x, 11.x to 11.6x inclusive
OS: All Supported Platforms
Other: ODBC Driver
Question/Problem Description
Sample PHP programs to access a Progress DB through SQL-92 ODBC Driver.
How to connect a PHP to a OpenEdge Database via ODBC
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
PHP (Hypertext Preprocessor) is a server-side, cross-platform, HTML embedded scripting language. It's freeware software that can be downloaded from the PHP Web site (

In order to run these programs an ODBC Driver is required on the Web Server machine.
  • Create a System Data Source Name called sp2k.
  • The Sports2000 Database should be running
  • There should be a SQL-92 user defined as "sysprogress" with password "s".
The following two PHP examples produce the same HTML page.
  • The first example uses the PHP function odbc_result_all() which prints all the records with a specific format.
  • The second example, records are printed "manually" one by one.
First PHP example, using odbc_result_all():
<? php $sql="SELECT * FROM PUB.Customer";

if ($conn_id=odbc_connect("sp2k","sysprogress","s", SQL_CUR_USE_ODBC)){

echo "connected to DSN: $dsn";

if($result=odbc_do($conn_id, $sql)) {
echo "executing '$sql'";
echo " Results: ";
odbc_result_all($result, "BGCOLOR='#AAFFAA' border=3 width=30% bordercolordark='#FF0000'");

echo "freeing result";


echo "can not execute '$sql' ";

echo " closing connection $conn_id";

echo " can not connect to DSN: $dsn ";
Second PHP example, printing "manually" record by record:

If the constant, SQL_CUR_USE_ODBC, is not used in the odbc_connect function, the same records is repeated several times.
if ($conn_id=odbc_connect("sp2k","sysprogress","s", SQL_CUR_USE_ODBC )){

echo " connected to DSN: sports91b ";

if($cur=odbc_exec($conn_id, "SELECT * FROM PUB.Customer")) {

$Fields = odbc_num_fields($cur);

print "<=table border='1' width='100%'> <=tr>'";

// Build Column Headers

for ($i=1; $i <= $Fields; $i++){
printf("<=th bgcolor='silver'>%s <=/th>", odbc_field_name( $cur,$i)); }

// Table Body

while( odbc_fetch_row( $cur )){
print "<=tr>";

for($i=1; $i <= $Fields; $i++){
printf("<=td>%s<=/td>", odbc_result( $cur, $i ));
print "<=/tr>";
print "<=/table>";
print " Your request returned $Outer rows!";

odbc_close( $conn_id);

Note:  If the ODBC connection is not working( e.g. receiving Internal Server Error 500) do the following:
Within the /etc/php.ini configuration file, search for “display_errors” and set the parameter to On.  
There may be two locations where this parameter is mentioned, ensure that only one is uncommented.
display_errors = On
Once set, rerun the PHP code and more information about the cause of the error should be displayed. 
Progress Articles:

000031743, Using PHP with OpenEdge ODBC driver on Unix/Linux
000035694, How to configure the 64-bit OpenEdge ODBC driver to work with PHP on CentOS/RedHat/Oracle Linux versions 5 or 6, via Source builds.  
000027930, How to configure the 64-bit OpenEdge ODBC driver to work with PHP on CentOS/RedHat/Oracle Linux versions 5, 6 or 7 via Yum (embedded video)      

DISCLAIMER: This example code is provided for informational purposes only. Its inclusion in the Progress Support Knowledgebase does not constitute endorsement of it or support for it, nor does it guarantee that it has been tested to the extent recommended for application deployment. Programmers are advised that they use it at their own risk.
Last Modified Date6/17/2019 7:47 AM