You don't need the loop at all, since you only want the total number of rows and not any of the rows themselves.
In fact, you don't want the loop: the number of rows in the result set has nothing to do with what is in those rows (which is why you're using $result6 but never use $row6); but if there are no rows in the result, the interior of the loop is never reached, because the while() condition immediately fails. So $k is never updated.
FURTHERMORE: it's stupid to select everything about every comment for a picture if the only thing you want to now is how many there are.
It's also a bad smell if you have a query inside a loop; especially one that's driven by another query.
It's also a performance hit to SELECT * instead of the columns you want.
You can get the count of the number of comments against each picture at the same time you're getting the pictures.
SELECT picture.picid, thumb, ... COUNT(*) as countcomments
FROM pictures,pic_comments
WHERE pic_comments.picid = pictures.picid
GROUP BY pictures.picid
Something along those lines.
And please, in future, use the [noparse]
...
[/noparse] tags around your code; as you can see, it makes things much easier to read.