Guest User

Mysql Stored Procedure Error (mysqli version)

a guest
Apr 11th, 2018
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. echo "<h1>Running test_procedure_1</h2>";
  2. echo "<pre>";
  3. echo "CREATE PROCEDURE `test_procedure_1`()".
  4. "BEGIN".
  5. "   select 'gary';".
  6. "   CALL raise_error;".
  7. "END";
  8. echo "</pre>";
  9. //connect to database
  10. $connection = new mysqli($db['server'], $db['user'], $db['password'], $db['name']);
  11.  
  12. if (!($result = $connection->query("CALL test_procedure_1"))) {
  13.     echo "CALL failed: (" . $connection->errno . ") " . $connection->error;
  14. }
  15. else{
  16.     //loop the result set
  17.     echo "RESULTS:";
  18.     while ($row = $result->fetch_assoc()){
  19.         print_r($row);
  20.     }
  21. }
  22.  
  23.  
  24. echo "<br>----------<br>";
  25. echo "<h1>Running test_procedure_2</h2>";
  26. echo "<pre>";
  27. echo "CREATE PROCEDURE `test_procedure_2`()".
  28. "BEGIN".
  29. "   CALL raise_error;".
  30. "   select 'gary';".
  31. "END";
  32. echo "</pre>";
  33. $connection = new mysqli($db['server'], $db['user'], $db['password'], $db['name']);
  34.  
  35. if (!($result2 = $connection->query("CALL test_procedure_2"))) {
  36.     echo "CALL failed: (" . $connection->errno . ") " . $connection->error;
  37. }
  38. else{
  39.     //loop the result set
  40.     echo "RESULTS:";
  41.     while ($row = $result2->fetch_assoc()){
  42.         print_r($row);
  43.     }
  44. }
RAW Paste Data