Edit report at http://bugs.php.net/bug.php?id=53647&edit=1
ID: 53647 Updated by: ahar...@php.net Reported by: justus at abi007 dot info Summary: mysql_num_rows falsely returns NULL on error -Status: Open +Status: Bogus -Type: Documentation Problem +Type: Bug Package: MySQL related Operating System: Ubuntu 10 Server PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Failed parameter checks within PHP functions result in NULL being returned. This is expected (and standard) behaviour across the PHP standard library. Closing. Previous Comments: ------------------------------------------------------------------------ [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