Query call in php hangs other queries

Asked

Viewed 38 times

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 the mysqli_query.

  • after the second query: Out of sync commands; you cannot execute this command now

  • Try mysqli_store_result($conexao); mysqli_free_result() after the 1st query

  • Error persists the same way

  • It only works if I do it like this: mysqli_close($connected); include "dbconexao.php"; but I think it’s wrong...

  • 1

    See this other question: https://answall.com/questions/16290/mysql-commands-out-of-sync-you-cant-run-this-command-now

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.