php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31637 Reproducible garbage array using MYSQL_ASSOC
Submitted: 2005-01-21 15:34 UTC Modified: 2005-01-28 23:16 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: david@php.net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Linux 2.4.28
Private report: No CVE-ID: None
 [2005-01-21 15:34 UTC] david@php.net
Description:
------------
mysql_fetch_array with MYSQL_ASSOC returns bogus array keys and some corrupted data fields in 4.3.10 (but not 4.3.9). Reproducible always with this particular query. Reproduced in both dotdeb.org packaged version and minimal cli version compiled from source:

./configure '--enable-cli' '--disable-cgi' '--disable-debug' '--disable-debug' '--disable-pear' '--without-pear' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock'

May be related to the long DESCRIPTION field in the first result row, but problem does not occur if LIMIT is changed to anything other than 6 (hence, sorry for the long expected/actual output!)

Reproduce code:
---------------
<?
$connection = mysql_connect("localhost", "test", "test")  or die("Could not connect to database.");
mysql_select_db("test") or die("Could not select database.");

        $query = "SELECT * FROM STORE_ITEM WHERE SUBSECTION_NAME IS NULL AND pkSTORE_ITEM_ID NOT IN (406, 407, 408) ORDER BY pkSTORE_ITEM_ID DESC LIMIT 6";
        $result = mysql_query($query) or trigger_error("Featured Item Select Query Failed.", E_USER_ERROR);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                print '<pre>'; print_r($row); print '</pre>';
        }

?>


Expected result:
----------------
(from 4.3.9)

<pre>Array
(
    [pkSTORE_ITEM_ID] => 404
    [fkSTORE_ARTIST_ID] => 33
    [ITEM_TYPE] => the drama magazine
    [ITEM_NAME] => The Drama Issue Four
    [ITEM_NAME_ABBR] => Issue Four
    [ARTIST_NAME] =>
    [DESCRIPTION] => Our fourth issue, The Inside/Out Issue, includes 88 pages in a mixture of black/white & full color and perfect-bound. We've got a wraparound cover and ten-page feature on New Jersey artist Matt Leines, exclusive artwork and interviews with <a href="http://www.keepsakesociety.com" target="_blank">Chris Duncan</a>, <a href="http://www.hackleyspress.com" target="_blank">David Abbott</a>, <a href="http://www.workbymarco.com" target="_blank">Marco Cibola</a>, <a href="http://www.tinyindustries.com" target="_blank">Megan Whitmarsh</a>, Isaac Lin, Marc Bell, <a href="http://www.madreal.com" target="_blank">Derrick Hodgson</a>, <a href="http://www.southersalazar.net" target="_blank">Souther Salazar</a>, & <a href="http://www.taylormckimens.com" target="_blank">Taylor McKimens</a>, photography by <a href="http://www.mayahayuk.com" target="_blank">Maya Hayuk</a>, <a href="http://www.crownfarmer.com" target="_blank">Bob Kronbauer</a>, & <a href="http://www.yerinmok.com" target="_blank">Ye Rin Mok</a>, a talk with several independent art galleries across the U.S., including <a href="http://www.branchgallery.com" target="_blank">Branch Gallery</a>, <a href="http://www.lumpgallery.com" target="_blank">Lump Gallery</a>, <a href="http://www.spectorspector.com" target="_blank">Spector Gallery</a>, <a href="http://www.artprostitute.com" target="_blank">Art Prostitute</a>, <a href="http://www.newimageartgallery.com" target="_blank">New Image Art</a>, <a href="http://www.reupmag.com" target="_blank">Selective Hearing Gallery</a>, & <a href="http://www.subliminalprojects.com" target="_blank">Subliminal Projects</a>, comics by Max Hubenthal & Travis Robertson, and much more. <br><br>Subscriptions are also available! Please click <a href="http://www.thedramastore.org/section.php?s=the%20drama%20subscription">here</a> for more information.
    [BASE_FILENAME] => magazine04
    [PRICE] => 6.00
    [OPTION1] =>
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 1
    [ORDER_ID] => 4
    [SUBSECTION_NAME] =>
)
</pre><pre>Array
(
    [pkSTORE_ITEM_ID] => 403
    [fkSTORE_ARTIST_ID] => 22
    [ITEM_TYPE] => misc
    [ITEM_NAME] => k.parel Button Set
    [ITEM_NAME_ABBR] =>
    [ARTIST_NAME] =>
    [DESCRIPTION] => A 2-button set by the kind folks at k.parel. Check out their website at <a href="http://www.kparel.com" target="_blank">www.kparel.com</a>. We like them.
    [BASE_FILENAME] => k01
    [PRICE] => 3.00
    [OPTION1] =>
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 0
    [ORDER_ID] => 12
    [SUBSECTION_NAME] =>
)
</pre><pre>Array
(
    [pkSTORE_ITEM_ID] => 402
    [fkSTORE_ARTIST_ID] => 44
    [ITEM_TYPE] => art
    [ITEM_NAME] => Time and Tide
    [ITEM_NAME_ABBR] =>
    [ARTIST_NAME] => Hackley's Press
    [DESCRIPTION] => 9-colour screenprint by Hackley's Press. Edition of 10.
    [BASE_FILENAME] => hackleys02
    [PRICE] => 40.00
    [OPTION1] =>
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 0
    [ORDER_ID] => 1
    [SUBSECTION_NAME] =>
)
</pre><pre>Array
(
    [pkSTORE_ITEM_ID] => 401
    [fkSTORE_ARTIST_ID] => 0
    [ITEM_TYPE] => misc
    [ITEM_NAME] => I Heart Gossip
    [ITEM_NAME_ABBR] =>
    [ARTIST_NAME] =>
    [DESCRIPTION] => Be the talk of the town with this super cute tote designed by Charles Wilkin of <a href="http://www.automatic-iam.com" target="_blank">Automatic</a>. They are made of 100% cotton canvas and available in red or yellow. The size is 13"x14".
    [BASE_FILENAME] => charles01
    [PRICE] => 15.00
    [OPTION1] =>
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 0
    [ORDER_ID] => 10
    [SUBSECTION_NAME] =>
)
</pre><pre>Array
(
    [pkSTORE_ITEM_ID] => 400
    [fkSTORE_ARTIST_ID] => 0
    [ITEM_TYPE] => misc
    [ITEM_NAME] => Art Pins
    [ITEM_NAME_ABBR] =>
    [ARTIST_NAME] =>
    [DESCRIPTION] => Hand-made art pins by Jason Hevener. Several to choose from!
    [BASE_FILENAME] => jason01
    [PRICE] => 3.00
    [OPTION1] => Choose, Bug Me, Bull, Ruff, Ninja (red), Jazz, I Heart Teeth
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 0
    [ORDER_ID] => 1
    [SUBSECTION_NAME] =>
)
</pre><pre>Array
(
    [pkSTORE_ITEM_ID] => 399
    [fkSTORE_ARTIST_ID] => 36
    [ITEM_TYPE] => prints by the mitten gallery
    [ITEM_NAME] => Postcard Set
    [ITEM_NAME_ABBR] =>
    [ARTIST_NAME] => The Mitten Gallery
    [DESCRIPTION] => Set of 5 silkscreened postcards from the Mitten Gallery.
    [BASE_FILENAME] => mitten04
    [PRICE] => 3.00
    [OPTION1] =>
    [OPTION2] =>
    [FLAG_SOLD_OUT] => 0
    [FLAG_FEATURED] => 0
    [ORDER_ID] => 4
    [SUBSECTION_NAME] =>
)


Actual result:
--------------
(from 4.3.10)

$ sapi/cli/php -n ~/drama-testcase.php
<pre>Array
(
    [B] => 404
    [   @] => 33
    [] => the drama magazine
    [] => 4
    [] =>
    [] => .com" target="_blank">Megan Whitmarsh</a>, Isaac Lin, Marc Bell, <a href="http://www.madreal.com" target="_blank">Derrick Hodgson</a>, <a href="http://www.southersalazar.net" Our fourth issue, The Inside/Out Issue, includes 88 pages in a mixture of black/white & full color and perfect-bound. We've got a wraparound cover and ten-page feature on New Jersey artist Matt Leines, exclusive artwork and interviews with <a href="http://www.keepsakesociety.com" target="_blank">Chris Duncan</a>, <a href="http://www.hackleyspress.com" target="_blank">David Abbott</a>, <a href="http://www.workbymarco.com" target="_blank">Marco Cibola</a>, <a href="http://www.tinyindustriestarget="_blank">Souther Salazar</a>, & <a href="http://www.taylormckimens.com" target="_blank">Taylor McKimens</a>, photography by <a href="http://www.mayahayuk.com" target="_blank">Maya Hayuk</a>, <a href="http://www.crownfarmer.com" target="_blank">Bob Kronbauer</a>, & <a href="http://www.yerinmok.com" target="_blank">Ye Rin Mok</a>, a talk with several independent art galleries across the U.S., including <a href="http://www.branchgallery.com" target="_blank">Branch Gallery</a>, <a href="http://www.lumpgallery.com" target="_blank">Lump Gallery</a>, <a href="http://www.spectorspector.com" target="_blank">Spector Gallery</a>, <a href="http://www.artprostitute.com" target="_blank">Art Prostitute</a>, <a href="http://www.newimageartgallery.com" target="_blank">New Image Art</a>, <a href="http://www.reupmag.com" target="_blank">Selective Hearing Gallery</a>, & <a href="http://www.subliminalprojects.com" target="_blank">Subliminal Projects</a>, comics by Max Hubenthal & Travis Robertson, and much more. <br><br>Subscriptions are also available! Please click <a href="http://www.thedramastore.org/section.php?s=the%20drama%20subscription">here</a> for more information.
    @] =>
)
</pre><pre>Array
(
    [B] => 403
    [   @] => 22
    [] => misc
    [] => 12
    [] =>
    [] => A 2-button set by the kind folks at k.parel. Check out their website at <a href="http://www.kparel.com" target="_blank">www.kparel.com</a>. We like them.
    @] =>
)
</pre><pre>Array
(
    [B] => 402
    [   @] => 44
    [] => art
    [] => 1
    [] =>
    [] => 9-colour screenprint by Hackley's Press. Edition of 10.
    @] =>
)
</pre><pre>Array
(
    [B] => 401
    [   @] => 0
    [] => misc
    [] => 10
    [] =>
    [] => Be the talk of the town with this super cute tote designed by Charles Wilkin of <a href="http://www.automatic-iam.com" target="_blank">Automatic</a>. They are made of 100% cotton canvas and available in red or yellow. The size is 13"x14".
    @] =>
)
</pre><pre>Array
(
    [B] => 400
    [   @] => 0
    [] => misc
    [] => 1
    [] =>
    [] => Hand-made art pins by Jason Hevener. Several to choose from!
    @] =>
)
</pre><pre>Array
(
    [B] => 399
    [   @] => 36
    [] => prints by the mitten gallery
    [] => 4
    [] =>
    [] => Set of 5 silkscreened postcards from the Mitten Gallery.
    @] =>
)
</pre>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-22 01:29 UTC] sniper@php.net
You ought to know better to not report bugs if you're not testing with latest snapshot. And also you should know that we don't like reports with too much to read. 
http://bugs.php.net/how-to-report.php

Come up with beter test case, nobody else than you can run the one you gave..

 [2005-01-28 23:11 UTC] david@php.net
I was unable to produce a simpler test case. However it 
does look to be a bug in the mysql client or server 
related to a ENUM field on the table with a large number 
of possible values. Closing here and escalating to 
mysql.
 [2005-01-28 23:16 UTC] tony2001@php.net
No bug in PHP -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 05:01:31 2024 UTC