ODBC connection error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toppac
Forum Commoner
Posts: 29
Joined: Fri Jun 14, 2002 10:44 am

ODBC connection error

Post by toppac »

I am trying to connect to an ODBC DSN to an oracle db. I run this line of code

Code: Select all

$connect = odbc_connect("dev1.world", "report", "report") or die("Couldn't connect to source");
and I get this error message
Warning: SQL error: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed, SQL state IM004 in SQLConnect in D:\Apache\Apache2\htdocs\toppc\odbcTest.php on line 3
I am not sure what this means or how to fix it.
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Use the Oracle OCI functions
toppac
Forum Commoner
Posts: 29
Joined: Fri Jun 14, 2002 10:44 am

Post by toppac »

Can you elaborate please
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

PHP has built in functions for Oracle either

Oracle 8 functions
http://www.php.net/manual/en/ref.oci8.php

or Oracle 7 functions
http://www.php.net/manual/en/ref.oracle.php

You need to enable the relevant extension in your PHP.INI file (windows), you also need the Oracle client on your server, relevant entries in your TNS Names file. I presume you can tnsping dev1 from your php server?

These functions do not use ODBC but connect directly to the Oracle dll's (I think) which can only be a good thing, not having to go through a Microsoft ODBC driver.
Post Reply