php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26049 Cannot connect to ODBC source (MyODBC)
Submitted: 2003-10-31 05:00 UTC Modified: 2003-10-31 11:02 UTC
From: miroslav dot sulc at startnet dot cz Assigned:
Status: Not a bug Package: ODBC related
PHP Version: 4.3.3 OS: Linux (Gentoo)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: miroslav dot sulc at startnet dot cz
New email:
PHP Version: OS:

 

 [2003-10-31 05:00 UTC] miroslav dot sulc at startnet dot cz
Description:
------------
I cannot connect with:
$var=odbc_connect('myodbc-test','root','password');
to my MyODBC data source.

Here is the error:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/lib/libmyodbc3.so' : unknown error, SQL state IM003 in SQLConnect in /home/httpd/bagr/docs/test.php on line 2

I would appreciate any help. Below is some more info.

isql command work fine:
echo "show tables;
> " | isql myodbc-test root password
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-command                           |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> +-----------------------------------------------------------------+
| Tables_in_test                                                  |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
0 rows affected


Here is PHP configuration:
'./configure' '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--without-readline' '--with-apxs2=/usr/sbin/apxs2' '--with-ndbm=/usr' '--with-db4=/usr' '--with-mcrypt=/usr' '--with-mhash=/usr' '--with-ming=/usr' '--with-swf=/usr' '--with-sybase=/usr' '--with-gdbm=/usr' '--with-java=/opt/blackdown-jdk-1.4.1' '--with-mcal=/usr' '--with-unixODBC=/usr' '--with-pgsql=/usr' '--with-snmp=/usr' '--enable-ucd-snmp-hack' '--with-pdflib=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-png' '--with-png-dir=/usr' '--with-jpeg' '--with-jpeg-dir=/usr' '--enable-exif' '--with-tiff' '--with-tiff-dir=/usr' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-freetype-dir=/usr' '--with-ttf=/usr' '--with-t1lib=/usr' '--with-gettext' '--without-qtdom' '--with-pspell=/usr' '--with-openssl=/usr' '--with-imap=/usr' '--with-ldap=/usr' '--with-dom=/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-kerberos=/usr' '--with-pam' '--disable-memory-limit' '--disable-ipv6' '--with-curlwrappers' '--with-curl=/usr' '--enable-dbx' '--with-imap-ssl' '--with-zlib' '--with-zlib-dir=/usr' '--with-sablot=/usr' '--enable-xslt' '--with-xslt-sablot' '--with-xmlrpc' '--enable-wddx' '--with-xml' '--enable-mbstring=all' '--enable-mbregex' '--with-bz2=/usr' '--with-crack=/usr' '--with-cdb' '--enable-bcmath' '--enable-calendar' '--enable-dbase' '--enable-filepro' '--enable-ftp' '--with-mime-magic' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvipc' '--with-iconv' '--enable-shmop' '--enable-dio' '--enable-inline-optimization' '--enable-track-vars' '--enable-trans-sid' '--enable-versioning' '--with-config-file-path=/etc/php/apache2-php4'

Here are versions:
unixODBC: 2.0.6
MyODBC: 3.51.06

/etc/unixODBC/odbc.ini:
[myodbc-test]
Description             = MySQL ODBC myodbc-3.51.06 Driver Testing DSN
Driver          = /usr/lib/libmyodbc3.so
Socket          = /var/run/mysqld/mysqld.sock
Server          = localhost
User            = root
Database                = test
Option          = 3

/etc/unixODBC/odbcinst.ini:
[myodbc]
Description             = MySQL ODBC Driver
Driver          = /usr/lib/libmyodbc3.so
FileUsage               = 1

File permissions:
ls -l /usr/lib/libmyodbc3*
-rwxr-xr-x    1 root     root       157984 Oct 30 10:28 /usr/lib/libmyodbc3-3.51.06.so
-rw-r--r--    1 root     root       175340 Oct 30 10:28 /usr/lib/libmyodbc3.a
-rwxr-xr-x    1 root     root          861 Oct 30 10:28 /usr/lib/libmyodbc3.la
lrwxrwxrwx    1 root     root           21 Oct 30 10:28 /usr/lib/libmyodbc3.so -> libmyodbc3-3.51.06.so

Apache runs as user apache and group apache.

php.ini diff against unpacked php.ini-dist from src distribution.
diff /etc/php/apache2-php4/php.ini php-4.3.3/php.ini-dist
428c428
< extension_dir = /usr/lib/php/extensions/no-debug-non-zts-20020429
---
> extension_dir = "./"
490,492c490
< ; allow_url_fopen = On
< ; Closed for security - <robbat2@gentoo.org>
< allow_url_fopen = Off
---
> allow_url_fopen = On
530c528
< ; extension_dir = /usr/lib/php/extensions/no-debug-non-zts-20020429
---
> ; extension_dir directive above.
556c554
< extension = java.so
---
> ;extension=php_java.dll
603c601
< java.class.path = /usr/lib/php/extensions/no-debug-non-zts-20020429/php_java.jar
---
> ;java.class.path = .\php_java.jar
605,606c603,604
< java.library = /opt/blackdown-jdk-1.4.1/jre/lib/i386/libjava.so
< java.library.path = /usr/lib/php/extensions/no-debug-non-zts-20020429
---
> ;java.library = c:\jdk\jre\bin\hotspot\jvm.dll
> ;java.library.path = .\

I hope it's enough.

Reproduce code:
---------------
$var=odbc_connect('myodbc-test','root','password');

Expected result:
----------------
Should connect without errors :-)

Actual result:
--------------
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/lib/libmyodbc3.so' : unknown error, SQL state IM003 in SQLConnect in /home/httpd/bagr/docs/test.php on line 2


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-31 09:22 UTC] kalowsky@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Please read how to configure your unixODBC system.  
 [2003-10-31 11:02 UTC] miroslav dot sulc at startnet dot cz
Does it mean that it is sure that this behaviour is caused by misconfiguration and not by PHP bug? Do you know what problem I am dealing with and what is the solution? I have been looking for an answer to my problem for several hours and found nothing usefull.
 [2003-12-09 11:18 UTC] sirb3r at yahoo dot ca
Same problem trying to get to Access:

Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/lib/libmdbodbc.so' : unknown error, SQL state IM003 in SQLConnect in /home/httpd/htdocs/migrate.php on line 3
 [2012-02-09 07:58 UTC] saketisthere at gmail dot com
Hello,

Hvae you modified the odbc.ini and odbcinst.ini files also you need to set your environment variables along with the LD_LIBRARY_PATH so that it finds that driver.

Currently it is not able to find the driver it needs to use to get connected

Saket Kale.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC