[PHP-DEV] PHP 4.0 Bug #6734 Updated: SQL Error In using ODBC connection to Oracle From: Bug Database (php-dev <email protected>)
Date: 09/14/00

ID: 6734
User Update by: eballou <email protected>
Status: Open
Old-Bug Type: Oracle related
Bug Type: ODBC related
Description: SQL Error In using ODBC connection to Oracle

Previous Comments:
---------------------------------------------------------------------------

[2000-09-14 01:23:04] eballou <email protected>
Installed PHP4.02 on NT 4 and 98. NT has IIS3/PWS and 98 has PWS. Install went fine on 98 after following numerous notes. After installing on NT scripts are able to run, however I am unable to connect to Oracle DB. I haven't figured out where the oracle module is (or how to install it for PHP) so I use ODBC connection and script. Granted the code isn't pretty as I get errors with the output, but it works on the 98 machine fine.

I get the following error:

Warning: SQL error: [Oracle][ODBC][Ora]Server rejected the connection., SQL state 08004 in SQLConnect in D:Reportsbad.php on line 19
Error in odbc_connect
Warning: Supplied argument is not a valid ODBC result resource in D:Reportsbad.php on line 14

Suggestions and instructions needed.

Code also follows:

<?
//__________________________________________________________
//
// test_odbc.php3
// A sample PHP script to test ODBC under PHP / WinNT
// Leo West - 08/1998
//__________________________________________________________
 
 
function Error_Handler( $msg, $cnx )
{
        echo "$msg n";
                // in case of persistent connexion, it is important to close it before exiting.
        odbc_free_result( $cnx);
        exit();
}
 
        // create an ODBC connection, returned in $cnx
        $cnx = odbc_connect( "WebDB","SA","");
 
// To avoid permission troubles in the test, you may want to use a superadmin access :
// $cnx = odbc_connect( 'WebDB' , [sa login] , [sa password] );
 
        if( ! $cnx ) {
                Error_handler( "Error in odbc_connect" , $cnx );
        }
 
        // send a simple odbc query . returns an odbc cursor
        $cur= odbc_exec( $cnx, "select name from matters order by name" );
        if( ! $cur ) {
                Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
        }
 
 
        echo "<table border=1><tr><th>id</th><th>nom</th></tr>n";
        $nbrow=0;
 
                // fetch the succesive result rows
        while( odbc_fetch_row( $cur ) )
        {
                $nbrow++;
                        // get the field "id"
                $id= odbc_result( $cur, 1 );
                        // get the field "nom"
                $nom= odbc_result( $cur, 2 );
                echo "<tr><td>$id</td><td>$nom</td></tr>n";
        }
 
        echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
        
                // close the connection. important if persistent connection are "On"
        odbc_close( $cnx);
 
?>

---------------------------------------------------------------------------

Full Bug description available at: http://bugs.php.net/?id=6734

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>