PHP 4.0 Bug #6734: SQL Error In using ODBC connection to Oracle
| From: | eballou at wellfound dot com | Date: | Thu, 14 Sep 2000 05:23:04 +0000 |
| Subject: | PHP 4.0 Bug #6734: SQL Error In using ODBC connection to Oracle | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33190@lists.php.net to get a copy of this message | ||
From: eballou@wellfound.com
Operating system: NT 4.0 SP 4
PHP version: 4.0.2
PHP Bug Type: Oracle related
Bug description: SQL Error In using ODBC connection to Oracle
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:\Reports\bad.php on line 19
Error in odbc_connect
Warning: Supplied argument is not a valid ODBC result resource in D:\Reports\bad.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);
?>