I am trying to connect to Oracle through ODBC in PHP but so far have been unsuccessful.

My ODBC connection checks out OK and has the parameters shown in the attachment.

SERVER = STUDY (local machine)
DATABASE NAME = MYDB
etc

Here is what I have tried and the result:

$connectionstring = odbc_connect("DRIVER={Oracle in OraDb10g_home1};SERVER=STUDY;DATABASE=MYDB","system","*******");

results in ...

Warning: odbc_connect() [function.odbc-connect]: SQL error: Specified driver could not be loaded due to system error 5 (Oracle in OraDb10g_home1)., SQL state IM003 in SQLConnect in c:\Inetpub\wwwroot\ConnectORACLE.php on line 4

I have also tried various other things including:

$connectionstring = odbc_connect("Driver={Oracle in OraDb10g_home1}; ;UID=system; PWD=squeeze");

which results in ...

Warning: Wrong parameter count for odbc_connect() in c:\Inetpub\wwwroot\ConnectORACLE.php on line 5

I apologise that this is a basic question and I'm sure that the answer is straightforward but I am new and it's driving me mad.

I have no problem connection to SQL Server through ODBC using ...

$connectionstring = odbc_connect("DRIVER={SQL Server};SERVER=STUDY;DATABASE=tempdb", 'sa','');

Thanks for your help!

😕 :bemused: 🙁

    Hi,

    did you install an oracle odbc driver ?

    Besides that, what about installing the Oracle client on the web server and using the php oracle functions ?

    Thomas

      Yes I did install an Oracle ODBC driver. Well at least I think I have. Soryy this is all new to me! Listeners, SID's, etc.

      I know about the PHP plug-in but I specifically wanted to use ODBC as I am doing a comparison exercise and wanted everything to be on a level playing field.

      What would a typical Oracle ODBC connection string look like in PHP?

      Thanks

        Create a system DSN on the web server (control panel -> odbc sources) and then just use the dsn name with odbc_connect.

        odbc_connect($dsn,$user,$pass);

        Alternatively, try to use {Oracle ODBC Driver} instead of Oracle in OraDb10g_home1. But that depends on the driver.

        Which ODBC driver do you use ?

        Thomas

          Hi there - I tried both the Oracle and Microsoft drivers but both with no result.

          The interesting thing is that my ODBC connection tests out OK, it's just when I try to call it from PHP.

          I tried you suggestions for the connection strings but they both failed with the folling errors ...

          $connectionstring = odbc_connect("DRIVER={Oracle ODBC Driver};DSN=MYDB","system","***");
          $connectionstring = odbc_connect("MYDB","system","
          ***");

          gives ...

          Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\Inetpub\wwwroot\ConnectORACLE.php on line 4

          Warning: odbc_connect() [function.odbc-connect]: SQL error: Specified driver could not be loaded due to system error 5 (Oracle in OraClient10g_home3)., SQL state IM003 in SQLConnect in c:\Inetpub\wwwroot\ConnectORACLE.php on line 5

          Any other suggestions?:mad: 🙁

            Well it turned out to be the security permissions on the Oracle folder that were preventing the connection!
            All is working fine now.
            Thanks for your help anyway.

            Regards,

            Andy.

            🙂

              4 years later
              cab;10592598 wrote:

              Well it turned out to be the security permissions on the Oracle folder that were preventing the connection!
              All is working fine now.
              Thanks for your help anyway.

              Regards,

              Andy.

              🙂

              Hello Folk,
              I have the same plobleam, what oracle folder did you set a permissions ?

              thank' for help

              Cauca

                Hi there,

                Well this is a really old post and my memory is not that good.
                As far as I can recall I reset the permissions on the entire Oracle folder on the C drive (it will be called ora10 or similar)
                Hope this helps.

                Regards

                  cab;10920232 wrote:

                  Hi there,

                  Well this is a really old post and my memory is not that good.
                  As far as I can recall I reset the permissions on the entire Oracle folder on the C drive (it will be called ora10 or similar)
                  Hope this helps.

                  Regards

                  Wow Thank's friend,
                  In my case I gave permission in d:/database/oracle_10 to IIS_USER !!!
                  And really worked !!!

                  Thank's for help me!!!

                  God bless!

                  Cauca

                    Write a Reply...