ID: 22328 Updated by: [EMAIL PROTECTED] Reported By: miki_fossati at libero dot it -Status: Open +Status: Assigned Bug Type: MySQL related Operating System: linux suse 7.2 -PHP Version: 4.3.0 +PHP Version: 4.3.3RC2-dev -Assigned To: +Assigned To: georg New Comment:
Happens with PHP 4.3.3RC2-dev, Georg? :) Previous Comments: ------------------------------------------------------------------------ [2003-06-21 11:40:51] [EMAIL PROTECTED] Ok, I've removed the mysql_errno() check on fetchInto(). IMHO this is a bug in the mysql extension, which doesn't properly reset the error. This problem doesn't ocurr with postgres or interbase. Test script to reproduce the problem: <?php $con = mysql_connect('localhost', 'root'); mysql_selectdb('test'); $res = mysql_query('SELECT * FROM table'); $continue = true; do { $row = mysql_fetch_row($res); if (mysql_errno()) { // Here there is no fetch_row error, it's the same // from FAKE QUERY echo "Failed fetching with error: " . mysql_errno() . "\n"; // Don't want to continue on fetch errors $continue = false; } elseif (!$row) { $continue = false; } else { $res2 = mysql_query('FAKE QUERY'); echo "Failed to launch FAKE QUERY: " . mysql_errno() . "\n"; // Ok, I got the error but want to continue $continue = true; } } while ($continue); ?> Output: Failed to launch FAKE QUERY: 1064 Failed fetching with error: 1064 ------------------------------------------------------------------------ [2003-05-11 01:19:07] [EMAIL PROTECTED] Actually lsmith's fix seems to be fine. Is there anything speaking against applying it? ------------------------------------------------------------------------ [2003-04-29 15:14:00] [EMAIL PROTECTED] the problem is in the implementation of fetchInto: function fetchInto($result, &$arr, $fetchmode, $rownum=null) { if ($rownum !== null) { if ([EMAIL PROTECTED]($result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @mysql_fetch_array($result, MYSQL_ASSOC); } else { $arr = @mysql_fetch_row($result); } if (!$arr) { $errno = @mysql_errno($this->connection); if (!$errno) { return NULL; } return $this->mysqlRaiseError($errno); } return DB_OK; } this line picks up the error that was meant for the "FAKE QUERY" and think by mistake that therefore not the end of the result set was reached but an error occured. Since during a fetch only a connection error can occur it might be a good idea to remove the mysql_errno() call in order to fix this. Alternative we could check for a connection error: if (!$arr) { $errno = @mysql_errno($this->connection); if ($errno == 2013) { return $this->mysqlRaiseError($errno); } return NULL; } $errno = @mysql_errno($this->connection); ------------------------------------------------------------------------ [2003-04-28 03:58:57] [EMAIL PROTECTED] changing status ------------------------------------------------------------------------ [2003-02-20 05:23:10] miki_fossati at libero dot it In the following code: --- starts here --- require_once 'DB.php'; $connString = "mysql://user:[EMAIL PROTECTED]/my_db"; $mysqlDb = DB::connect("$connString", true); $result = $mysqlDb->query("SELECT id FROM table WHERE name='foo' LIMIT 0, 3"); if (!DB::isError($result)) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { extract($row); echo "$id <br />"; $result2=$mysqlDb->query("FAKE QUERY"); if(!DB::isError($result2)) { //Never here } else { //Continue loop } } } --- ends here --- the loop continues forever. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22328&edit=1