http://rajinihasan.blogspot.com.au/2013/02/deleting-orphan-databases-sharepoint.html
after this you have to update the web application.
$webapp.update()
In our case,
The two timer jobs were running on the platform were stopping the update. then we had stopped the and then updated the web application and restore full back and attach the same.
You will be able to see the site collections available.
YOGESHA H P(MCTS)