I copied the code from /wp-admin/index.php to get the comment count from one blog and tried making it add up the comments for all the blogs across my wpmu install, but its not working:
<?php
require ('wp-config.php');
$res = mysql_query("SELECT blog_id from wp_blogs");
while ($line = mysql_fetch_array($res)) {
$id = $line['blog_id'];
$comments = (int) $wpdb->get_var("SELECT COUNT(*) FROM wp_${id}_comments WHERE comment_approved = '1'");
}
echo $id;
?>
What am I doing wrong? If I replace wp_${id}_comments with wp_1_comments it will give me the correct value. I just dont know how to make it all add up :D