Re: mysql_numrows

From: Date: Sun, 12 Oct 2008 21:54:54 +0000
Subject: Re: mysql_numrows
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-45523@lists.php.net to get a copy of this message
Ron Piggott wrote:
When I do the following command: $number_of_entries=mysql_numrows($blog_activity_result); and there are no rows I get an error (Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in ...)
Fix the error from $blog_activity_result as someone else mentioned. If there are no rows returned from a query, mysql_numrows will return 0 - it will only show an error if you give it a bad link identifier. eg $query = "select * from table_that_doesnt_exist limit 1"; $result = mysql_query($query); $rows = mysql_numrows($result); <-- will give an error $query = "select * from table_that_is_empty limit 1"; $result = mysql_query($query); $rows = mysql_numrows($result); <-- will return 0 -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#45523) next »