Edit report at http://bugs.php.net/bug.php?id=53647&edit=1
ID: 53647 Comment by: justus at abi007 dot info Reported by: justus at abi007 dot info Summary: mysql_num_rows falsely returns NULL on error Status: Bogus Type: Bug Package: MySQL related Operating System: Ubuntu 10 Server PHP Version: Irrelevant Block user comment: N Private report: N New Comment: That this is the expected behaviour is the point, because the documentation implies it isn't. Please correct me if I'm wrong, but this "standard behaviour" is undocumented behaviour and thus useless. If this means writing the proposed update into every "Result Values" field, then so be it, right now it's not even close to ideal. Regards, Justus Previous Comments: ------------------------------------------------------------------------ [2011-01-04 13:02:51] ahar...@php.net Failed parameter checks within PHP functions result in NULL being returned. This is expected (and standard) behaviour across the PHP standard library. Closing. ------------------------------------------------------------------------ [2011-01-04 12:18:14] justus at abi007 dot info Description: ------------ mysql_num_rows returns NULL for invalid input data, like Strings/Booleans/Null/etc. In regards to the documentation this should be bool(false) http://php.net/mysql_num_rows "Return Values The number of rows in a result set on success or FALSE on failure." Because it is likely better that invalid input data leads to a different failure handling I propose that you add "or NULL for invalid input data" to the documentation of Return Values to fix this. Test script: --------------- <? var_dump(mysql_num_rows('test')); ?> Expected result: ---------------- bool(false) Actual result: -------------- Warning: mysql_num_rows() expects parameter 1 to be resource, string given in - on line 2 NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53647&edit=1