This is the right code
<li id="last_comments">
<?php _e('Last Comments:'); ?>
<ul>
<?php
$query = "SELECT ID, comment_post_ID, comment_author, comment_content FROM $tableposts, $tablecomments WHERE $tableposts.ID=$tablecomments.comment_post_ID ORDER BY $tablecomments.comment_date DESC LIMIT 5";
$result = mysql_query($query);
while ($data = mysql_fetch_row($result)) {
if (!$data[2]) {
$data[2]="Anonymous";
}
echo "<li>";
echo "[$data[2]] <a href="index.php?p=$data[1]#comments">";
echo substr($data[3],'0','80');
echo "...</a></li>";
} ?>
</ul>
</li>