PDO::ERRMODE_EXCEPTION )); } catch (Exception $e) { die("Error : ".$e->getMessage()); } if (isset($_SESSION['username'])) { $req = $db->prepare('SELECT id FROM `authors` WHERE username=:username'); $req->execute(array( "username"=>$_SESSION['username'] )); $data = $req->fetch(); $user_id = $data['id']; $req = $db->prepare('SELECT COUNT(*) AS counter FROM `messages` WHERE message_to=:user_id AND message_read=0'); $req->execute(array( "user_id"=>$user_id )); $data = $req->fetch(); $new_msg_number = $data['counter']; if ($new_msg_number != 0) { ?>