correggo:

if(count($msg_db) == 0 && $msg_db[0] == "") {

con

if(count($msg_db) == 1 && $msg_db[0] == "") {