php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17875 sizeof() reports double the elements for an mssql_fetch_array
Submitted: 2002-06-20 11:56 UTC Modified: 2002-06-20 12:30 UTC
From: cusaacb at squared dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.1 OS: Linux
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: cusaacb at squared dot com
New email:
PHP Version: OS:

 

 [2002-06-20 11:56 UTC] cusaacb at squared dot com
// correct behavior
$arr = array();

$arr[0] = "One";
$arr[1] = "Two";
$arr[2] = "Three";

print "Normal:&nbsp&nbsp&nbsp";
print sizeof($arr) . "<BR><BR>";


//show bug


$rs = mssql_query("select '1' as one, '2' as two, '3' as three from tablename");

$sqlarr = mssql_fetch_array($rs);

print "Bug:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";

//-----  HERES THE BUG
print sizeof($sqlarr) . "\n";

./configure  --prefix=/usr/local/php --with-sybase=/usr/local/freetds --with-pgsql=/usr/local/pgsql --with-apxs2=/usr/local/apache2/bin/apxs

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-20 12:07 UTC] sander@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"mssql_fetch_array() is an extended version of mssql_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys."
 [2002-06-20 12:30 UTC] cusaacb at squared dot com
OK. I see.  If you want to just iterate over the fields you would use mssql_fetch_row() instead.

Sorry and Thanks,
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC