Bug #62879 [Opn->Nab]: Incorrect Array Size when fetching Array

From: Date: Tue, 21 Aug 2012 16:13:08 +0000
Subject: Bug #62879 [Opn->Nab]: Incorrect Array Size when fetching Array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-172763@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62879&edit=1 ID: 62879 Updated by: rasmus@php.net Reported by: joseph dot morain at live dot ca Summary: Incorrect Array Size when fetching Array -Status: Open +Status: Not a bug Type: Bug Package: MySQLi related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: mysqli_fetch_array() by default gives you both numeric and associative indices for each row. Pass in MYSQLI_ASSOC or MYSQLI_NUM to get just one of them. Previous Comments: ------------------------------------------------------------------------ [2012-08-21 16:03:14] joseph dot morain at live dot ca Description: ------------ Hi I'm using PHP 5.4.4 (Didn't see option for this). I have a trivial table called staff with 3 rows and 1 record staff_id : 555 email : baconator_king@baconation.com password : 1_b@c0n@73_8Ab1Es whenever I try to fetch array however it multiplies the data by 2! I've posted a short little program which illustrates my problem. There is a similar problem here : https://bugs.php.net/bug.php?id=60333 but it was dealing with a slightly different function so I didn't append that bug report. Test script: --------------- include('_commons.php'); $con = dbopen(); $results = mysqli_query($con,'SELECT * FROM Staff;'); while($row = mysqli_fetch_array($results)){ foreach($row as $t){ echo $t.'<br/>'; } } dbclose($con); Expected result: ---------------- 555 baconator_king@baconation.com 1_b@c0n@73_8Ab1Es Actual result: -------------- 555 555 baconator_king@baconation.com baconator_king@baconation.com 1_b@c0n@73_8Ab1Es 1_b@c0n@73_8Ab1Es ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62879&edit=1

« previous php.bugs (#172763) next »