Edit report at https://bugs.php.net/bug.php?id=54978&edit=1
ID: 54978 Comment by: radu dot dineiu at gmail dot com Reported by: radu dot dineiu at gmail dot com Summary: mysql_query() returns true with a SELECT statement Status: Feedback Type: Bug Package: MySQL related Operating System: Any PHP Version: 5.3.6 Assigned To: mysql Block user comment: N Private report: N New Comment: Yes, this happens with PHP's mysql_* functions using libmysqlclient, not mysqlnd. I don't know if it happens with mysqlnd as well, I couldn't test that, and now I can't get the same environment again. Previous Comments: ------------------------------------------------------------------------ [2011-07-20 10:55:15] u...@php.net Are you using libmysql, if so, which version? Can you reproduce with mysqlnd? And, yes, looks like we need the patch. I wonder if its libmysql version dependent. Thanks! ------------------------------------------------------------------------ [2011-06-02 17:38:28] radu dot dineiu at gmail dot com Description: ------------ This doesn't happen often, but it does happen sometimes when the database server interrupts the connection during a query. Seems to be related to the fact that libmysqlclient's mysql_query() may return success, even if an error occurred, as described at: http://dev.mysql.com/doc/refman/5.5/en/null-mysql-store-result.html Test script: --------------- $resource = mysql_query('SELECT test FROM test'); if ($resource === true) { throw new Exception('mysql_query() returned true for SELECT'); } Expected result: ---------------- An exception should not be thrown, because the documentation for mysql_query() at php.net clearly states that a SELECT query will only ever return false or a resource. Actual result: -------------- An exception is thrown, because mysql_query() returns true with a SELECT query. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54978&edit=1