Within the while loop add
var_dump($menu); and post that. Assuming that the <a/> is a typo just in the forum here, the output you have is consistent with 'cat_name' containing the value
Name</a>\n<a>. So lets start there.
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php