php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10980 mssql query error
Submitted: 2001-05-21 02:57 UTC Modified: 2001-05-30 09:01 UTC
From: njgreen at jlonline dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.4pl1 OS: windows2000/98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: njgreen at jlonline dot com
New email:
PHP Version: OS:

 

 [2001-05-21 02:57 UTC] njgreen at jlonline dot com
//error source
$connid=odbc_connect('odbc_db','odbc_user','odbc_pswd');
$sql='select id from bt_article where id<>978';
$row=odbc_do($connid,$sql);
echo odbc_num_rows($row);

//result -1
//if $sql='select title from bt_article where id<>978 order by id';
//result is ok
//if $sql='select title from bt_article where id=978 order by id';
//result -1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-22 05:28 UTC] fmk@php.net
ODBC related should not be reported as MSSQL related.

Furthermore I think we need some more information about this error.

Are you getting other results than expected ? What is 'result' ? You dont have any variables in the code with that name.

If 'result' is the output from odbc_num_rows() we need to know the structure of the table and what you expect from your data.
 [2001-05-22 11:36 UTC] njgreen at jlonline dot com
hi,
  Thank you for helping.

I'm sorry,The 'result' is output of 'odbc_num_rows() '.
I expect get the record from 'bt_article',what  
bt_article.id equal a value;

My bt_article struct :
id int(4) in
title char(40)

 [2001-05-30 09:01 UTC] kalowsky@php.net
From PHP user Matt White:

 The MS-SQL driver doesn't support the odbc_num_rows() function.  There are several workarounds listed in the comments in the annotated manual...

// Return the number of rows affected by the last query.
function numberOfRowsSelected()
{
    // Weird bug. MS-SQL's ODBC driver doesn't support the num_rows function.
    $NumRecords = 0; 
        
    odbc_fetch_row($this->lastSqlResult, 0); 
    while (odbc_fetch_row($this->lastSqlResult)) 
    { 
        $NumRecords++; 
    } 

    //odbc_fetch_row($this->lastSqlResult, $currentRow); 
    return $NumRecords; 
} 

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 00:01:29 2025 UTC