473,498 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select From Db2 W/php Error

SimonJ621
12 New Member
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
3 2391
Purple
404 Recognized Expert Contributor
Hi Jason,

What platform is the webserver running on ?

Does the odbc datasource test ok ?

Regards Purple
Aug 15 '07 #2
SimonJ621
12 New Member
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
12 New Member
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

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

Similar topics

1
9881
by: Greg Bryant | last post by:
Hi folks. I'm porting a cf site to php, everything's going very well, I like php much better (this, of course, being the correct forum to make that statement :). One problem I have is with...
9
3612
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am...
0
10153
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
3
6424
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
19
8340
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
16
2716
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
3
6409
by: iitt2007 | last post by:
In my SP, I am using SELECT @error_message= 'string' . My collegue asked me to use SET@error_message= 'string' , I would like to know the differences for using SELECT vs SET. Here's the snippet...
2
3395
by: kxyz | last post by:
Hello everyone, I need help with a stored procedure or two. My stored procedures are supposed to check if a certain record exists. If it does exist, then I select everything from that row, as...
2
1715
by: FlashCreations | last post by:
Hello, I am trying to use javascript to validate a form that has three select inputs. Here is the form: <form name="select" action="main.php" method="post" onsubmit="return ValidateSelect(this)"> ...
2
1919
by: msridhar87 | last post by:
hi, am doing a multi server chat program using select()..in the client side i need to multiplex thei/p from server and stdin. #include <stdio.h> #include <sys/types.h> #include <sys/socket.h>...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.