Best way to tell if a comment is from a user?

You can simplly check

if ($comment->user_id > 0){
//comment by registered user
}else{
//comment by none registered user
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)