elepil
asked on
PHP: How to call a stored procedure
The following code snippet was created in MySQL Workbench:
But I'm having a problem on the PHP side. Here's the code in PHP:
I am getting a PHP error that says, "Fatal error: Call to a member function fetch() on boolean in C:\xampp\htdocs\newdimensi on\public\ DBPrep.php ".
Can someone please tell me what I'm doing wrong? Thanks.
DELIMITER //
CREATE PROCEDURE getCustomers()
BEGIN
SELECT * FROM customers;
END //
DELIMITER ;
CALL getCustomers(); // This works just fine, I get the result set
But I'm having a problem on the PHP side. Here's the code in PHP:
$stmt = $db->prepare("call getCustomers()");
$result = $stmt->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo $row['custid'] . '<br/>';
}
I am getting a PHP error that says, "Fatal error: Call to a member function fetch() on boolean in C:\xampp\htdocs\newdimensi
Can someone please tell me what I'm doing wrong? Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help, guys.