× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Attempting to perform a simple select using a PHP and db2_prepared statements. Running the query directly works fine (first part of code). When I run the db2_execute($stmt, $params), I get an error saying "Statement Execute Failed" with a SQL Error Code of 22023. Can anyone see what I'm doing wrong here?

PHP Code Below

<?php
$conn = db2_connect($database, $username, $password, $options);

$sql = "SELECT count(*) FROM CUSTOMERS WHERE acctnbr = ". $_REQUEST['accountNumber'];
$stmt = db2_exec($conn, $sql);
while ($row = db2_fetch_array($stmt)) {
print "$row[0]\n";
}
print "THIS WORKS <hr />";



//Checking to see if connection was successful.
if($conn){
//Building and running query
$params = array($_REQUEST['accountNumber']);
$query = "SELECT count(*) FROM CUSTOMERS WHERE acctnbr = ?";
$stmt = db2_prepare($conn, $query);
if (!$stmt) {
die("You got problems.");
}

print "Got here.";
db2_execute($stmt, $params);
//Displays Warning: db2_execute(): Statement Execute Failed in /www/api/validateAccountNumber.php on line 27 (above)
print "<hr />". db2_stmt_error(). "<hr />";
//Displays "22023"
while (db2_fetch_row($stmt)) {
//NEVER GET HERE
$found = db2_result($stmt, 0);
print $found . " record(s) found.";
}
print "Also got here.";
//Closing database connection
db2_close($conn);

}else{
$output['@error']['database'] = 'Database connection error';
}






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.