midrange.com code scratchpad
Name:
PHP db2_Execute Error with Stored Procedure
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
12/01/2010 06:42:17 pm
IP:
Logged
Description:
Error with PHP Stored Procedure Call - db2_Execute
Code:
  1. <?php
  2.  
  3. require 'include/RTRStandardFunctions.php';
  4.  
  5. //$vendor = strtoupper($_POST['vendor']);
  6. //$model = strtoupper($_POST['model']);
  7.  
  8. $vendor = 'MYVENDOR';
  9. $model = 'MYMODEL';
  10.  
  11. $db2connection = RTRdb2Connect();
  12. echo $db2connection;
  13. echo "<br>";
  14. // Prepare Stored Procedure call //
  15. $proc = 'CALL INVENTORY.SPR101R(?, ?)';
  16. $stmt = db2_prepare($db2connection, $proc);
  17. if (!$stmt) {
  18.     echo 'Prepare failed: '.db2_stmt_error().':'.db2_stmt_errormsg();
  19.     die("db2_prepare failed<br>");
  20. }
  21. // Define parameters //
  22. db2_bind_param($stmt, 1, "$vendor", DB2_PARAM_IN);
  23. db2_bind_param($stmt, 2, "$model", DB2_PARAM_IN);
  24.  
  25. // Display results set //
  26. if (db2_execute($stmt)) {
  27.     while ($row = db2_fetch_array($stmt)) {
  28.         print "  {$row[0]}, {$row[1]} <br>";
  29.     }
  30. }
  31. else {
  32.     echo 'Execute failed: '.db2_stmt_error().':'.db2_stmt_errormsg();
  33.     die("db2_execute failed<br>");
  34. }  
  35.  
  36. ?>
  37.  
  38.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css