From:             cyclops at prof-x dot net
Operating system: Linux (Debian Stable)
PHP version:      5.1.2
PHP Bug Type:     MySQL related
Bug description:  returned array (by mysql_fetch_array($res,MYSQL_ASSOC)) has 
'weird' keys.

Description:
------------
I have some weird behaviour of mysql_fetch_array with mysql_assoc...

- Query: SELECT id, title, text, filename, timedate FROM news WHERE
deleted = 'N' ORDER BY timedate DESC LIMIT 0,5

- print_r of array returned by mysql_fetch_array($res, MYSQL_ASSOC):
Array
(
    [#B] => 133
    [   @] => Name
    [EMAIL PROTECTED] => Text
    [] => Filename
    [รก] => 2006-03-14 14:01:44
)

changing the query into results in this:
- Query: SELECT id, title, text , filename, timedate FROM news WHERE
deleted = 'N' ORDER BY timedate DESC LIMIT 0,5

- print_r of array returned by mysql_fetch_array($res, MYSQL_ASSOC):
Array
(
    [id] => 133
    [title] => Name
    [text] => Text
    [filename] => filename
    [timedate] => 2006-03-14 14:01:4
}

Note the space after 'text'. I also have some different result when i
change the limit from '0,5' to '1,5'.


This also breaks mysql_fetch_object returning a error:

PHP Fatal error:  Cannot access empty property in /root/text.php on line
29


Reproduce code:
---------------
function GetLastNews($type = NULL) {
        $con = dbConnect();
        $arr = Array();

        $q2 = "SELECT id, title, text , filename, timedate FROM news WHERE
deleted = 'N' ORDER BY timedate DESC LIMIT 0,5";
        $res = mysql_query($q2,$con);
        if ($res) {
                while ($news = mysql_fetch_array($res,MYSQL_ASSOC)) {
                        print_r($news);
                }
                dbClose($con);
                return $arr;
        }
        dbClose($con);
        return NULL;
}


Expected result:
----------------
see description

Actual result:
--------------
see description

-- 
Edit bug report at http://bugs.php.net/?id=37001&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37001&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37001&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37001&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37001&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37001&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37001&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37001&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37001&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37001&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37001&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37001&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37001&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37001&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37001&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37001&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37001&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37001&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37001&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37001&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37001&r=mysqlcfg

Reply via email to