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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 + 3 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC