Call count result from stored procedure MySQL in PHP

377

I'm trying to get a value from a stored procedure in php but I can't do it.

My stored procedure:

DROP PROCEDURE IF EXISTS sp_table;
DELIMITER $$
CREATE PROCEDURE sp_table()
BEGIN
SELECT COUNT(*) FROM table;
END$$
DELIMITER ;

My PHP code:

$recordSet_table = $conn->query("CALL sp_table()");

print_r($recordSet_table)."<br><br>";
886

Answer

Solution:

Please try following code.

$sql = mysqli_query($connectionVariable,"CALLsp_table(@count)");

$result = mysqli_fetch_array($sql);

People are also looking for solutions to the problem: php - Secure unsubscribe link - How much encryption is enough?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.