1
Because when doing a first query to a call and then trying to do another php hangs? For example, run this stored simple file in php
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `curtidas_sp` (
IN `@post` INT
)
SELECT
COUNT(*) AS c_total,
FROM curtidas
WHERE id_post = `@post`$$
DELIMITER ;
running in php:
$f_dados = mysqli_query($conexao, "CALL curtidas_sp('$idPost')");
$f_resultado = mysqli_fetch_assoc($f_dados);
And then try to run down another being or not a call
$c_dados = mysqli_query($conexao, "SELECT COUNT(*) AS f_total, FROM favoritos WHERE id_post = 2");
$c_resultado = mysqli_fetch_assoc($c_dados);
Displays this error:
mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given...
Mariadb, Innodb, PHP7, Stored Procedure.
See what comes out in
mysqli_error($conexao)
, after executing each of themysqli_query
.– bfavaretto
after the second query: Out of sync commands; you cannot execute this command now
– João Victor
Try
mysqli_store_result($conexao); mysqli_free_result()
after the 1st query– bfavaretto
Error persists the same way
– João Victor
It only works if I do it like this: mysqli_close($connected); include "dbconexao.php"; but I think it’s wrong...
– João Victor
See this other question: https://answall.com/questions/16290/mysql-commands-out-of-sync-you-cant-run-this-command-now
– bfavaretto