Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    6

    Unanswered: 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:

    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

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    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 14:33.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You can send my the payment via PayPal. Just kidding.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Aug 2007
    Posts
    6
    Duetschland huh... Ich werde das Geld bald schicken

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •