简体   繁体   中英

PHP warning odbc_connect() SQL Error

I just installed an iSeriesODBC-5.1.0-0.16.i386.rpm on my ubuntu linux 12.04 32bit OS. What im trying to do is connect to a DB2 AS400.

When I run this code below:

<?php 

$JDALIB = 'MMMMMM';

$DSN = "DRIVER=iSeries Access ODBC Driver;SYSTEM=dev_ip;DBQ=$JDALIB";
$connect = odbc_connect($DSN, "USERNAME", "PASSWORD", SQL_CUR_USE_IF_NEEDED);

gave me an

PHP Warning:  odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /home/odbc_connection.php on line 6

So what i did was to install unixODBC and freeTDS and I did install them successfully but when I run again my connection script. Still same error result. Can anyone help me.

Not sure why you would install freeTDS, thats to connect to SQL Server or Sybase.

Also, not sure where DBQ is from, that looks more like a MS Access connection attribute.

You could try

$DSN = "DRIVER={iSeries Access ODBC Driver};HOSTNAME=dev_ip;Database=$JDALIB";

But I would try and get it working with isql first, there are docs on the unixODBC site that describe getting DB2 connections working.

I would try to create a DSN and get that working before trying to use a DSN less connection as you are doing.

Have a read of http://www.unixodbc.org/doc/db2.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM