#38924 [NEW]: mssql_next_result returns FALSE on multiple Resultsets

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #38924 [NEW]: mssql_next_result returns FALSE on multiple Resultsets

    From: info at benjamin-wilger dot de
    Operating system: Windows
    PHP version: 4.4.4
    PHP Bug Type: MSSQL related
    Bug description: mssql_next_result returns FALSE on multiple Resultsets

    Description:
    ------------
    mssql_next_result returns FALSE on multiple Resultsets if a simple select
    has been executed and the data is fetched before. If one doesn't run a
    query before running a multiple query batch (e.g. Stored Procedure) it
    works fine. Look at the reproduce code to completly understand the
    problem.

    Tested on PHP 4.3.11 (*not* buggy), 4.4.1 (*not* buggy), 4.4.2 (buggy),
    4.4.3 (buggy), 4.4.4 (buggy), 5.1.4 (buggy).

    Reproduce code:
    ---------------
    <?php
    mssql_connect(...); mssql_select_db(...);
    $result = mssql_query('SELECT 1');
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }

    $result = mssql_query('SELECT 1 SELECT 2 SELECT 3'); // Would return three
    rows
    do {
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }
    } while ($next_result = mssql_next_result($result)); // Will return FALSE
    in any version after 4.4.1 in this case


    Expected result:
    ----------------
    On systems with PHP 4.4.1 or lower it will run fine $rows_first_query has
    one row
    $rows_second_query has *three* rows

    Actual result:
    --------------
    Any version above (including 5.1.x branch) will return just one row in
    $rows_second_query.

    WORKAROUND to get it running: Run mssql_free_result() after the every
    fetching of data.

    --
    Edit bug report at [url]http://bugs.php.net/?id=38924&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=38924&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=38924&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=38924&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=38924&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=38924&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=38924&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=38924&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=38924&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=38924&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=38924&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=38924&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=38924&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=38924&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=38924&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=38924&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=38924&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=38924&r=mysqlcfg[/url]
    info at benjamin-wilger dot de Guest

  2. Similar Questions and Discussions

    1. #40234 [NEW]: gethostbynamel always returns false when using PHP as CGI
      From: silverbanana at gmx dot de Operating system: Windows XP SP2 PHP version: 6CVS-2007-01-25 (snap) PHP Bug Type: Network...
    2. #39281 [NEW]: glob() returns false
      From: johan dot ekman1 at comhem dot se Operating system: windows xp, apache PHP version: 5.1.6 PHP Bug Type: ...
    3. [PHP-DEV] [PATCH] substr() returns false
      --=-sQWDp5Weadel0FX8XkrW Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Even though this is documented, it is strange...
    4. mail() function returns FALSE
      Hi All, I'm having trouble getting sendmail to behave with the php mail() function. The function is returning FALSE. Today it doesn't seem to want...
    5. mail() returns FALSE, no err msg
      Sometimes my mail() function returns FALSE, but there is no error message. Error reporting is set to E_ALL. It seems to be a problem of the bcc:...
  3. #2

    Default #38924 [Opn->Bgs]: mssql_next_result returns FALSE on multiple Resultsets

    ID: 38924
    Updated by: [email]fmk@php.net[/email]
    Reported By: info at benjamin-wilger dot de
    -Status: Open
    +Status: Bogus
    Bug Type: MSSQL related
    Operating System: Windows
    PHP Version: 4.4.4
    New Comment:

    You should always release the result when you are done with it or use a
    new variable name for each result if you want to keep multiple results
    open.

    Two ways to make your code work:

    <?php
    $con = mssql_connect("localhost", "sa", "s2sihaviv");
    $result = mssql_query('SELECT 1', $con);
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }
    $result2 = mssql_query('SELECT 13; SELECT 2; SELECT 3', $con); // Would
    return three rows
    do {
    while($row = mssql_fetch_array($result2)) {
    $rows_first_query[] = $row;
    }
    } while ($next_result = mssql_next_result($result2)); // Will return
    FALSE

    print_r($rows_first_query);
    ?>


    <?php
    $con = mssql_connect("localhost", "sa", "s2sihaviv");
    $result = mssql_query('SELECT 1', $con);
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }
    mssql_free_result($result);
    $result = mssql_query('SELECT 13; SELECT 2; SELECT 3', $con); // Would
    return three rows
    do {
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }
    } while ($next_result = mssql_next_result($result)); // Will return
    FALSE

    print_r($rows_first_query);
    ?>


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-09-22 11:16:53] info at benjamin-wilger dot de

    Description:
    ------------
    mssql_next_result returns FALSE on multiple Resultsets if a simple
    select has been executed and the data is fetched before. If one doesn't
    run a query before running a multiple query batch (e.g. Stored
    Procedure) it works fine. Look at the reproduce code to completly
    understand the problem.

    Tested on PHP 4.3.11 (*not* buggy), 4.4.1 (*not* buggy), 4.4.2 (buggy),
    4.4.3 (buggy), 4.4.4 (buggy), 5.1.4 (buggy).

    Reproduce code:
    ---------------
    <?php
    mssql_connect(...); mssql_select_db(...);
    $result = mssql_query('SELECT 1');
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }

    $result = mssql_query('SELECT 1 SELECT 2 SELECT 3'); // Would return
    three rows
    do {
    while($row = mssql_fetch_array($result)) {
    $rows_first_query[] = $row;
    }
    } while ($next_result = mssql_next_result($result)); // Will return
    FALSE in any version after 4.4.1 in this case


    Expected result:
    ----------------
    On systems with PHP 4.4.1 or lower it will run fine $rows_first_query
    has one row
    $rows_second_query has *three* rows

    Actual result:
    --------------
    Any version above (including 5.1.x branch) will return just one row in
    $rows_second_query.

    WORKAROUND to get it running: Run mssql_free_result() after the every
    fetching of data.


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=38924&edit=1[/url]
    fmk@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139