If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > selecting from db2 with php error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-07, 18:31
SimonJ621 SimonJ621 is offline
Registered User
 
Join Date: Aug 2007
Posts: 6
selecting from db2 with php error

I am trying to select from a DB2 database with PHP. To my knowledge, the connection is being made, but the select statement won't run. The following is the error I receive:

Quote:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [IBM][CLI Driver][DB2/AIX64] SQL0644N Invalid value specified for keyword "CONCURRENCY" in statement "<ATTRIBUTE-STRING>". SQLSTATE=42615 , SQL state 42615 in SQLExecDirect in C:\wamp\www\db.php on line 24
I can't find much help online, which is why I am posting here. Any help would be much appreciated as I have never attempted to use DB2. Following is my PHP code:


PHP Code:
<?php 



function dbconnect($verbose) {

    
$dbname "**";

    
$username "**";

    
$password "**";

    

    
$dbconn odbc_pconnect($dbname$username$password);

    

    if ((
$verbose == TRUE) && ($dbconn == )) {

        echo(
"connection to database failed.");

        
$sqlerror odbc_errormsg($dbconn);

        echo  
"<br /><br />".$sqlerror."<br /><br />";

    }

    

    return(
$dbconn);

}





function 
display($dbconn) {

    
$select_stmt "SELECT * FROM blabla";



    if (
$dbconn != 0) {

        
$result odbc_exec($dbconn$select_stmt);

        if (
$result == 0) {

            echo 
"SELECT statement failed.<br />";

            
$sqlerror odbc_errormsg($dbconn);

        }

        else {

            
odbc_result_all($result);

        }

    }

}



$verbose TRUE;

$dbconn dbconnect($verbose);



display($dbconn);





?>
Thank you for all the help,

Jason
__________________
------------------------------------
http://www.elefoo.com
http://www.blackspyraldancer.com
Reply With Quote
  #2 (permalink)  
Old 08-16-07, 04:45
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Don't use the PHP ODBC driver. It is very buggy.

There is a DB2-specific PHP driver available, which is also supported by the DB2 development team.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 08-17-07, 08:17
SimonJ621 SimonJ621 is offline
Registered User
 
Join Date: Aug 2007
Posts: 6
Thanks Stolze,

I used db2_connect and it worked fine. The following code worked:

PHP Code:
$conn db2_connect($dbname$username$password);

if (
$conn) {
   
$sql "SELECT * FROM Table1";
   
$stmt db2_prepare($con$sql);
   
db2_execute($stmt);

   
$rows = array();
   
$i 0;

   while (
db2_fetch_row($stmt)) {
      
$rows[$i] = db2_result($stmt0);
      echo 
$rows[$i]."<br />";
      
$i++;
   }
}
else {
   echo 
"Connection failed. <br />";
   echo 
db2_conn_errormsg();

Thanks again.

Jason
------------------------------
http://www.elefoo.com/
http://www.blackspyraldancer.com/

Last edited by SimonJ621; 08-17-07 at 13:33.
Reply With Quote
  #4 (permalink)  
Old 08-17-07, 13:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can send my the payment via PayPal. Just kidding.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 08-17-07, 13:34
SimonJ621 SimonJ621 is offline
Registered User
 
Join Date: Aug 2007
Posts: 6
Duetschland huh... Ich werde das Geld bald schicken
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On