ID:               40687
 Updated by:       [EMAIL PROTECTED]
 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 PROTECTED]

Your query returns multiple results. The first is for the insert
statement and the second for the select. Take a look at
http://us3.php.net/odbc_next_result 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 http://bugs.php.net/?id=40687&edit=1

Reply via email to