php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22498 mysql_fetch_array / assoc return row twice
Submitted: 2003-03-01 16:38 UTC Modified: 2003-03-04 10:33 UTC
From: yvan dot garnier at laposte dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.2.3 OS: Linux Mandrake 9
Private report: No CVE-ID: None
 [2003-03-01 16:38 UTC] yvan dot garnier at laposte dot net
Query with grouping options return row twice when trying
to have associative array as result :
$sql ="SELECT MAX(date_send) AS max_date,idmess FROM sending WHERE user='me' GROUP BY idmess HAVING max_date<(NOW()-INTERVAL 1 MONTH)"
$res_sql=mysql_query($id_cnx,$sql)
Using any of :
$res = mysql_fetch_array($res_sql,MYSQL_ASSOC)
or $res = mysql_fetch_assoc($res_sql)
foreach ( $res as $field=>$value ) {
echo "field name ".$field." value = ".$value }
This return each row twice with the same values while
MAX function with GROUP BY would return only one
This query works fine in MySQL console
This is also running correctly using mysql_fetch_objet
while ( $res = mysql_fetch_object($res_sql)) {
echo "field name ".$res->idmess." value ".$res->max_date
return only one row per value

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-02 12:10 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

4.3.1 is already out..

 [2003-03-04 10:33 UTC] yvan dot garnier at laposte dot net
Upgraded to 4.3.1
Problem fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 16:01:29 2024 UTC