#40687 [NEW]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

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

  1. #1

    Default #40687 [NEW]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    From: scottsdev at gmail dot com
    Operating system: Linux
    PHP version: 5.2.1
    PHP Bug Type: ODBC related
    Bug description: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.
    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1, val_2,
    val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in D:\inetpub\wwwroot\php\xyz\lib\xxxx.php
    on line 11111

    So I really don't understand how to remove this error, and what to do so
    that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]


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

  2. Similar Questions and Discussions

    1. Error Executing Database Query.
      The error occurred in C:\CFusionMX7\wwwroot\CFIDE\gettingstarted\tutorial\index.cfm: line 2 2 : <cfquery name="atrwork"...
    2. #25972 [Ana]: ODBC truncates multi-byte text (w/ MSSQL)
      ID: 25972 Updated by: kalowsky@php.net Reported By: phpbug at chipple dot net Status: Analyzed Bug Type: ...
    3. #25972 [Ver->Ana]: ODBC truncates multi-byte text (w/ MSSQL)
      ID: 25972 Updated by: moriyoshi@php.net Reported By: phpbug at chipple dot net -Status: Verified +Status: ...
    4. #25972 [Opn]: ODBC truncates multi-byte text (w/ MSSQL)
      ID: 25972 User updated by: phpbug at chipple dot net Reported By: phpbug at chipple dot net Status: Open Bug Type: ...
    5. #25972 [NEW]: ODBC truncates multi-byte text (w/ MSSQL)
      From: phpbug at chipple dot net Operating system: Win2K 5.00.2195 SP4 PHP version: 4.3.4RC2 PHP Bug Type: ODBC related Bug...
  3. #2

    Default #40687 [Opn->Bgs]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    ID: 40687
    Updated by: [email]fmk@php.net[/email]
    Reported By: scottsdev at gmail dot com
    -Status: Open
    +Status: Bogus
    Bug Type: ODBC related
    Operating System: Linux
    PHP Version: 5.2.1
    New Comment:

    Your query returns multiple results. The first is for the insert
    statement and the second for the select. Take a look at
    [url]http://us3.php.net/odbc_next_result[/url] to see how to move to the second
    result.


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

    [2007-03-02 00:43:53] scottsdev at gmail dot com

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.

    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
    val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in
    D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111

    So I really don't understand how to remove this error, and what to do
    so that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]



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


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

  4. #3

    Default #40687 [Bgs->Opn]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    ID: 40687
    User updated by: scottsdev at gmail dot com
    Reported By: scottsdev at gmail dot com
    -Status: Bogus
    +Status: Open
    Bug Type: ODBC related
    -Operating System: Linux
    +Operating System: Windows Server
    PHP Version: 5.2.1
    New Comment:

    No Sir,

    Still it don't work. I put the if condition which check whether Next
    Result is found or not, and it come inside that clause and show error
    in fetch_array line.

    ==================

    $query = <<<END_SQL
    $query;
    select SCOPE_IDENTITY();
    END_SQL;

    $results = odbc_exec($conn, $query) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    if (odbc_next_result){
    while ( $row = odbc_fetch_array($results))
    {

    =========================================

    It still showing same error at

    ==> while ( $row = odbc_fetch_array($results))

    Error:
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in D:\inetpub\wwwroot\php\xyz\aaa.php on
    line 1111111


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

    [2007-03-02 18:19:47] [email]fmk@php.net[/email]

    Your query returns multiple results. The first is for the insert
    statement and the second for the select. Take a look at
    [url]http://us3.php.net/odbc_next_result[/url] to see how to move to the second
    result.

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

    [2007-03-02 00:43:53] scottsdev at gmail dot com

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.

    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
    val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in
    D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111

    So I really don't understand how to remove this error, and what to do
    so that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]



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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40687&edit=1[/url]
    scottsdev at gmail dot com Guest

  5. #4

    Default #40687 [Opn->Bgs]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    ID: 40687
    Updated by: [email]fmk@php.net[/email]
    Reported By: scottsdev at gmail dot com
    -Status: Open
    +Status: Bogus
    Bug Type: ODBC related
    Operating System: Windows Server
    PHP Version: 5.2.1
    New Comment:

    There is no bug here.

    odbc_next_result() sjould be called with a odbc result resource as the
    parameter. That's the only way it can advnance the internal result
    pointer to the next result.

    You code should look like this:

    if (odbc_next_result($results)){
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }
    }

    or

    // Move to the last result
    while (odbc_next_result($results));
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }




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

    [2007-03-02 21:10:54] scottsdev at gmail dot com

    No Sir,

    Still it don't work. I put the if condition which check whether Next
    Result is found or not, and it come inside that clause and show error
    in fetch_array line.

    ==================

    $query = <<<END_SQL
    $query;
    select SCOPE_IDENTITY();
    END_SQL;

    $results = odbc_exec($conn, $query) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    if (odbc_next_result){
    while ( $row = odbc_fetch_array($results))
    {

    =========================================

    It still showing same error at

    ==> while ( $row = odbc_fetch_array($results))

    Error:
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in D:\inetpub\wwwroot\php\xyz\aaa.php on
    line 1111111

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

    [2007-03-02 18:19:47] [email]fmk@php.net[/email]

    Your query returns multiple results. The first is for the insert
    statement and the second for the select. Take a look at
    [url]http://us3.php.net/odbc_next_result[/url] to see how to move to the second
    result.

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

    [2007-03-02 00:43:53] scottsdev at gmail dot com

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.

    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
    val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in
    D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111

    So I really don't understand how to remove this error, and what to do
    so that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]



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


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

  6. #5

    Default #40687 [Bgs->Csd]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    ID: 40687
    User updated by: scottsdev at gmail dot com
    Reported By: scottsdev at gmail dot com
    -Status: Bogus
    +Status: Closed
    Bug Type: ODBC related
    Operating System: Windows Server
    PHP Version: 5.2.1
    New Comment:

    Hey Gr8,

    Thanks Sir. I really did silly mistake by not providing argument in
    odbc_next_result. I passed resource id. And it start to work.

    Thanks for your Gr8 Help.

    J. Scott
    (Project Manager)


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

    [2007-03-02 21:58:56] [email]fmk@php.net[/email]

    There is no bug here.

    odbc_next_result() sjould be called with a odbc result resource as the
    parameter. That's the only way it can advnance the internal result
    pointer to the next result.

    You code should look like this:

    if (odbc_next_result($results)){
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }
    }

    or

    // Move to the last result
    while (odbc_next_result($results));
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }



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

    [2007-03-02 21:10:54] scottsdev at gmail dot com

    No Sir,

    Still it don't work. I put the if condition which check whether Next
    Result is found or not, and it come inside that clause and show error
    in fetch_array line.

    ==================

    $query = <<<END_SQL
    $query;
    select SCOPE_IDENTITY();
    END_SQL;

    $results = odbc_exec($conn, $query) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    if (odbc_next_result){
    while ( $row = odbc_fetch_array($results))
    {

    =========================================

    It still showing same error at

    ==> while ( $row = odbc_fetch_array($results))

    Error:
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in D:\inetpub\wwwroot\php\xyz\aaa.php on
    line 1111111

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

    [2007-03-02 18:19:47] [email]fmk@php.net[/email]

    Your query returns multiple results. The first is for the insert
    statement and the second for the select. Take a look at
    [url]http://us3.php.net/odbc_next_result[/url] to see how to move to the second
    result.

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

    [2007-03-02 00:43:53] scottsdev at gmail dot com

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.

    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
    val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in
    D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111

    So I really don't understand how to remove this error, and what to do
    so that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]



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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40687&edit=1[/url]
    scottsdev at gmail dot com Guest

  7. #6

    Default #40687 [Csd->Bgs]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction

    ID: 40687
    Updated by: [email]tony2001@php.net[/email]
    Reported By: scottsdev at gmail dot com
    -Status: Closed
    +Status: Bogus
    Bug Type: ODBC related
    Operating System: Windows Server
    PHP Version: 5.2.1


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

    [2007-03-03 00:15:14] scottsdev at gmail dot com

    Hey Gr8,

    Thanks Sir. I really did silly mistake by not providing argument in
    odbc_next_result. I passed resource id. And it start to work.

    Thanks for your Gr8 Help.

    J. Scott
    (Project Manager)

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

    [2007-03-02 21:58:56] [email]fmk@php.net[/email]

    There is no bug here.

    odbc_next_result() sjould be called with a odbc result resource as the
    parameter. That's the only way it can advnance the internal result
    pointer to the next result.

    You code should look like this:

    if (odbc_next_result($results)){
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }
    }

    or

    // Move to the last result
    while (odbc_next_result($results));
    while ($row = odbc_fetch_array($results)) {
    // Do your stuff
    }



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

    [2007-03-02 21:10:54] scottsdev at gmail dot com

    No Sir,

    Still it don't work. I put the if condition which check whether Next
    Result is found or not, and it come inside that clause and show error
    in fetch_array line.

    ==================

    $query = <<<END_SQL
    $query;
    select SCOPE_IDENTITY();
    END_SQL;

    $results = odbc_exec($conn, $query) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    if (odbc_next_result){
    while ( $row = odbc_fetch_array($results))
    {

    =========================================

    It still showing same error at

    ==> while ( $row = odbc_fetch_array($results))

    Error:
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in D:\inetpub\wwwroot\php\xyz\aaa.php on
    line 1111111

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

    [2007-03-02 18:19:47] [email]fmk@php.net[/email]

    Your query returns multiple results. The first is for the insert
    statement and the second for the select. Take a look at
    [url]http://us3.php.net/odbc_next_result[/url] to see how to move to the second
    result.

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

    [2007-03-02 00:43:53] scottsdev at gmail dot com

    Description:
    ------------
    Hello,

    I used DSN to established connection with MSSQL using following Cursor.

    Code is >>>

    $conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
    die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");

    I am getting following error when i tried to execute query like ...
    $sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
    val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
    $results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
    $query</pre>");

    //////////////////////////////
    if(!$results)
    {
    $this->error("<H2>No results!</H2>\n");
    return false;
    }else {
    $data = array();
    while ( $row = odbc_fetch_array($results))
    {
    $data = $row;
    }
    odbc_free_result($results);
    $last_Id = $data['LastInsertedID'];
    }

    ==================================================

    So errors occurs
    on this line: while ( $row = odbc_fetch_array($results))

    Error is :
    Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
    available at this result index in
    D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111

    So I really don't understand how to remove this error, and what to do
    so that such two query can be run at once and return the result.

    J. Scott
    [scottsdev at gmail dot com]



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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40687&edit=1[/url]
    tony2001@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