0

I have this php code:

    // Sentences
    $sqlsentence  = "CALL getPartidos_All(0, 25, 2, 20, NULL, NULL);";
    $sqlsentence .= "CALL getNumRows";

    if (mysqli_multi_query($con, $sqlsentence)) {  // RETURN TRUE

        // First query result
        if ($result = mysqli_store_result($con)) {  // RETURN TRUE
            print '<table border="1">';
            while ($fila = mysqli_fetch_row($result)) {
                print '<tr>';
                print '<td>'.$fila[0].'</td>';
                print '<td>'.$fila[1].'</td>';
                //...and so on
                print '</tr>';
            }
            print '</table>';
            mysqli_free_result($result);
        }


        // Second query result
        if (mysqli_more_results($con) && mysqli_next_result($con)) { // RETURN TRUE
            if ($resultRows = mysqli_store_result($con)) {  // RETURN FALSE !!
                print '<table border="1">';
                while ($fila = mysqli_fetch_row($resultRows)) {
                    print '<tr>';
                    print '<td>'.$fila[0].'</td>';
                    print '</tr>';
                }
                print '</table>';
                mysqli_free_result($resultRows);
            }
        }
    }

This code retrieve corretly rows at first procedure (CALL getPartidos_All(0, 25, 2, 20, NULL, NULL);).

But return nothing at second procedure, although (mysqli_more_results($con) && mysqli_next_result($con)) returns true. I don't understand.

Both queries work. (I checked it.)

das-g
  • 9,718
  • 4
  • 38
  • 80
Tomas
  • 23
  • 5
  • remove the `;` from first query and check once. – Alive to die - Anant Jun 20 '15 at 20:04
  • I remove the semicolon and the first query neither works – Tomas Jun 20 '15 at 20:28
  • check $con->error after mysqli_next_result($con) – yuk Jun 20 '15 at 20:46
  • I've seen lots of questions about `mysqli_multi_query`, it never seems to work for people. Just use two calls to `mysqli_query`. – Barmar Jun 20 '15 at 20:58
  • It doesn't return any errors. – Tomas Jun 20 '15 at 21:00
  • @Barmar I did try it, but I need to do two query in the same mysqli session. (The first procedure contains an Select with SQL_CALC_FOUND_ROWS command, and the second procedure is a SELECT FOUND_ROWS()). – Tomas Jun 20 '15 at 21:02
  • If they use the same `$con` object, they're in the same session. – Barmar Jun 20 '15 at 21:03
  • @Barmar mysqli only allows execute one query. after this, you have to recreate the mysqli_connect. [link](http://stackoverflow.com/questions/10924127/two-mysqli-queries)[/link] – Tomas Jun 20 '15 at 21:37
  • That question is wrong. I have written many scripts that perform multiple queries on the same connection. – Barmar Jun 20 '15 at 23:03

0 Answers0