You should stick to Joomla coding standards for your query like so:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('username'))
->from($db->quoteName('#__users'))
->where($db->quoteName('id') . ' = ' . (int) 391));
$db->setQuery($query);
$result = $db->loadResult();
But if you are trying to get the username of s user with a specific ID, then you can simply use the following:
$user = JFactory::getUser(391);
$this->msg = 'Hello '. $user->get('username');