On Sun, Oct 12, 2008 at 5:54 PM, Chris <dmagick@xxxxxxxxx> wrote: > 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/ > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > The best bet is to handle the errors properly $num_rows = -1; if (!$result || mysql_err_no($result) != 0) { $num_rows = mysql_num_rows($result); } if ($num_rows >-1){ //do something here } -- Bastien Cat, the other other white meat