Page 1 of 1

Query data from AS400

Posted: Wed Feb 11, 2009 10:16 am
by yang_wayn
Hi All,

I want to use PHP to query AS400 data. I searched some articles. They all suggested using php-ODBC.

I wrote this code test:

Code: Select all

 
<?php
$server="172.16.10.X"; #the name of the iSeries
$user="XXXX"; #a valid username that will connect to the DB
$pass="XXXX"; #a password for the username
 
#Connect to the Database with ODBC - $conn is defined and loaded using the "odbc_connect" PHP #directive.
$conn=odbc_connect("$server,$user,$pass"); #you may have to remove quotes
 
#Check Connection
if ($conn == false) {
echo "Not able to connect to database...<br>";
}
 
#Query the Database into a result set - 
 
$result=odbc_exec($conn,"SELECT * from library.file where somefield=a value");
 
#...do other stuff here...
 
#don't forget to close the connection when you're done
 
odbc_close($conn);
?>
 
 
I got error message:
Fatal error: Call to undefined function: odbc_connect() in /opt/lampp/logicreate/services/mos/templates/admin.html on line 13

I searched this error message. http://www.easysoft.com/developer/langu ... _odbc.html
It said to installed php-odbc-4.2.2-17.i386.rpm from RedHat. (But I have SLES 9)
I have - Apache 2.2.9, - PHP 4.4.9

When I try to install

Code: Select all

rpm -i php-odbc-4.2.2-17.i386.rpm
[/quote]

It said:  Failed dependencies:
        php = 4.2.2-17 is needed by php-odbc-4.2.2-17

Please help me and let me know if I am in right direction.

Thanks in advance.


Lisa

Re: Query data from AS400

Posted: Wed Feb 11, 2009 9:06 pm
by itp
You may want to post here for PHP-AS/400 questions.
http://forums.systeminetwork.com/isnetf ... y.php?f=13

As an alternative, did you know you can also run PHP native on as/400. Zend/IBM offer a library of tools for access and integration.
http://files.zend.com/help/Zend-Core-i5 ... or_api.htm

Re: Query data from AS400

Posted: Thu Feb 12, 2009 8:38 am
by yang_wayn
Thanks for your links.

But since we don't use zend framework, I may not go to i5_connect.