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 > problem in db2_exec

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-28-09, 12:21
zero1987 zero1987 is offline
Registered User
 
Join Date: May 2009
Posts: 8
problem in db2_exec

please help me . why I can't use db2_exec? I use db2 ver 9 and php use wampserver, windows xp. then I get message

Warning: db2_exec() [function.db2-exec]: Statement Execute Failed in C:\wamp\www\Yushan\web_application_with_db2\getrep ort.php on line 71

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Hasil Laporan</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
    background-color: #FFF;
    font-size: 82%;
    color: #000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
  
// Prevent SQL Injection
  
if(get_magic_quotes_gpc()!=&& is_array($_GET)) foreach($_GET as $k=>$v) if(is_string($v)) $_GET[$k] = addslashes($v);
    
    
    
    
$r_ID trim($_GET['txtID']);
    
$r_Barcode trim($_GET['txtBarcode']);
    
$r_Nama trim($_GET['txtNama']);
    
$r_Arrival trim($_GET['txtArrival']);
    
$r_Confirmation trim($_GET['txtConfirmation']);
    
$r_Paper trim($_GET['txtPaper']);
    
$r_Serial trim($_GET['txtSerial']);
    
$r_Condition trim($_GET['txtCondition']);
    
$r_Location trim($_GET['txtLocation']);
    
$r_OrderBy $_GET['ob'];
    
    
    if(
$r_Arrival!='') {
      
$r_oper_arrival '=';
      if(
$_GET['ao']=='before'$r_oper_arrival '<=';
      if(
$_GET['ao']=='after'$r_oper_arrival '>=';
    }
    
    if(
$r_Confirmation!='') {
      
$r_oper_confirmation '=';
      if(
$_GET['co']=='before'$r_oper_confirmation '<=';
      if(
$_GET['co']=='after'$r_oper_confirmation '>=';
    }
    
    
    
    if(
$r_ID!=''$sql_kondisi_temp[] = "id='$r_ID'";
    if(
$r_Barcode!=''$sql_kondisi_temp[] = "Barcode='$r_Barcode'";
    if(
$r_Nama!=''$sql_kondisi_temp[] = "NamaBarang LIKE '%$r_Nama%'";
    if(
$r_Arrival!=''$sql_kondisi_temp[] = "ArrivalDate $r_oper_arrival '$r_Arrival'";
    if(
$r_Confirmation!=''$sql_kondisi_temp[] = "ConfirmationDate $r_oper_confirmation '$r_Confirmation'";
    if(
$r_Paper!=''$sql_kondisi_temp[] = "PaperNumber='$r_Paper'";
    if(
$r_Serial!=''$sql_kondisi_temp[] = "SerialNumber='$r_Serial'";
    if(
$r_Condition!=''$sql_kondisi_temp[] = "Condition LIKE '%$r_Condition%'";
    if(
$r_Location!=''$sql_kondisi_temp[] = "Location LIKE '%$r_Location%'";
    
    if(
is_array($sql_kondisi_temp)) $sql_kondisi implode(' AND '$sql_kondisi_temp);
    if(
$sql_kondisi!=''$sql_kondisi " WHERE $sql_kondisi ";
    
$sql_order_by " ORDER BY $r_OrderBy ";
    
    
$dbuser="Yushan1987";
    
$dbpassword="dragon";
    
$dbname="LAB";
    
$koneksidb2_pconnect($dbname,$dbuser,$dbpassword) or exit("Koneksi ke DB2 gagal");
    
    
$sql "SELECT * FROM INVENTORY $sql_kondisi $sql_order_by";
    
    
$run=db2_prepare($koneksi$sql);

    if(!(
$hasil=db2_exec($koneksi,$sql))) exit("DB2 Error");
    
    if(
db2_num_rows($hasil)==0) exit("Tidak ada data yang memenuhi kriteria.");
    
    for(
$i=0;$i<db2_num_rows($hasil);$i++) {
    
$row db2_fetch_array($hasil);
    
    
$row_temp '';
    
    foreach(
$row as $k=>$v$row_temp .= '<td><span style="margin-right: 6px;">' htmlspecialchars($v) . '</span></td>';
    
    if(
$prev_bg=='#FCFCFC'$prev_bg='#F0F0F0'; else $prev_bg='#FCFCFC';
    
    
$row_temp "<tr style=\"background-color: $prev_bg;\">$row_temp</tr>";
    
    
$table_temp .= $row_temp;
    
  }
    
  
  
$row_temp '';
  foreach(
$row as $k=>$v$row_temp .= '<td style="background-color: #F4EBE1;"><b>' $k '</b></td>';
  
$table_temp '<table cellpadding="5">' "$row_temp$table_temp</table>";
  
  echo 
$table_temp;
?>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 05-28-09, 17:45
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
- try executing a simpler statement
- try printing out the final statement and executing it manually
Reply With Quote
  #3 (permalink)  
Old 05-29-09, 11:53
zero1987 zero1987 is offline
Registered User
 
Join Date: May 2009
Posts: 8
i already try executing a simpler statement then same too error and I get message Warning: db2_exec() [function.db2-exec]: Statement Execute Failed. why can't be use db2_exec. please help me . please give me tutorial . because I don't understand and still study DB2
Reply With Quote
  #4 (permalink)  
Old 05-29-09, 11:53
zero1987 zero1987 is offline
Registered User
 
Join Date: May 2009
Posts: 8
i already try executing a simpler statement then same too error and I get message Warning: db2_exec() [function.db2-exec]: Statement Execute Failed. why can't be use db2_exec. please help me . please give me tutorial . because I don't understand and still study DB2. sorry my post twice because during the post error

Last edited by zero1987; 05-29-09 at 12:01.
Reply With Quote
  #5 (permalink)  
Old 06-01-09, 04:02
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I would access the full error information (including SQLCA) and that may give you the actual DB2 error code. Something else you can try is to look at the error log written by PHP. It will give you - with a sufficiently high trace level - a lot of additional information.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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