How to count the number of post by author in D7?
The result of db_query() should now be iterated over directly, db_fetch_object() isn't part of Drupal 7. 

You could also make use of the fetchField() method to get the result of your COUNT query:

$uid = $node-&gt;uid;
$args = array(':uid' =&gt; $uid);
$count = db_query('SELECT COUNT(nid) FROM {node} WHERE uid = :uid', $args)-&gt;fetchField();

print "&lt;p&gt;$node-&gt;name has submitted &lt;em&gt;&lt;strong&gt;$count&lt;/strong&gt;&lt;/em&gt; source code / articles.&lt;/p&gt;";


The above example uses the preferred method of passing arguments to a database query, it's safer than including them directly in the query string.

If you did want to loop over the results (for a query with more than one row/field) you'd do it like this:

$result = db_query('SELECT * FROM {node}');
foreach ($result as $row) {
  $nid = $row-&gt;nid;
}