I'm guessing the problem is the cable that connects your hard drive to the logic board. You can order a new one from eBay, Amazon, or other Apple suppliers, or set anup a Genius Bar appointment to have them diagnose and see if it is the issue.
A family member and I both had similar issues with our MacBooks.