ID: 37001 User updated by: cyclops at prof-x dot net Reported By: cyclops at prof-x dot net Status: Open Bug Type: MySQL related Operating System: Linux (Debian Stable) PHP Version: 5.1.2 New Comment:
This code works in PHP 4.3.10, found the bug when i wanted to upgrade to 5.x. Mysql version is 4.1.9. Previous Comments: ------------------------------------------------------------------------ [2006-04-06 20:37:50] cyclops at prof-x dot net 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 this bug report at http://bugs.php.net/?id=37001&edit=1