1

I've done below coding using php5.2 and mySql 5. Now I've upgraded my server to support php 5.3 and mySql 5.1.

    do
    {
        if ($this->Result = mysqli_store_result($this->LinkId))
        {
             while ($row = mysqli_fetch_array($this->Result , MYSQLI_ASSOC))
             {
                  $arrRes[] = $row;
             }
             mysqli_free_result($this->Result);
        }
    }while (mysqli_next_result($this->LinkId));

Am getting the following error:

There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method

What should I do?

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • 1
    @YourCommonSense no that does't works, server got downed while adding. Also forgot to tell this, above code is in do while loop. – Thangapandiyan M D May 08 '14 at 13:10
  • What doesn't work about it? Put `mysqli_more_results()` in the `while ()` condition and move the `mysqli_next_result()` inside the loop. I guess this will require a little code reorganisation because you won't want to do that first time through the loop. – Hammerite May 08 '14 at 14:13
  • @Hammerite can you able to give example for above code?. It will be helpful to reorganize. – Thangapandiyan M D May 09 '14 at 06:23

1 Answers1

5

You probably want to do something like this.

while (true) {
    if ($this->Result = mysqli_store_result($this->LinkId)) {
        while ($row = mysqli_fetch_array($this->Result , MYSQLI_ASSOC)) {
            $arrRes[] = $row;
        }
        mysqli_free_result($this->Result);
    }
    if (mysqli_more_results($this->LinkId)) {
        mysqli_next_result($this->LinkId);
    } else {
        break;
    }
}
Hammerite
  • 21,755
  • 6
  • 70
  • 91
  • For *normal* queries, we can use `$mysql->multi_query`. But how do we get the "multi" version of [`$mysql->prepare`](http://php.net/manual/en/mysqli.prepare.php)? – Pacerier Jun 29 '15 at 10:13
  • That looks like a topic distinct from this question, so maybe ask another question. I don't know whether there is a prepared statement version of `multi_query()` (but note that a single statement can generate multiple result sets, so there is a `more_results()` method on `mysqli_stmt`). – Hammerite Jun 29 '15 at 10:55