By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,589 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,589 IT Pros & Developers. It's quick & easy.

Select From Db2 W/php Error

SimonJ621
P: 12
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]<?php

function dbconnect($verbose) {
$dbname = "**";
$username = "**";
$password = "**";

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

if (($verbose == TRUE) && ($dbconn == 0 )) {
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);


?>[/PHP]


Thank you for all the help,

Jason
--------------------------
http://www.elefoo.com/
http://www.blackspyraldancer.com/
Aug 15 '07 #1
Share this Question
Share on Google+
3 Replies


Purple
Expert 100+
P: 404
Hi Jason,

What platform is the webserver running on ?

Does the odbc datasource test ok ?

Regards Purple
Aug 15 '07 #2

SimonJ621
P: 12
The datasource tests ok. I have the DB2 client on my Windows machine but the server itself runs on a UNIX box.
Aug 16 '07 #3

SimonJ621
P: 12
I used db2_connect instead of the odbc functions and it worked find. The following code worked:

[PHP]$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($stmt, 0);
echo $rows[$i]."<br />";
$i++;
}
}
else {
echo "Connection failed. <br />";
echo db2_conn_errormsg();
}[/PHP]

Thanks again.

Jason
------------------------------
http://www.elefoo.com/
http://www.blackspyraldancer.com/
Aug 17 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.