Ah i figured it out!
Pretty simple when i look at it, there was nothing wrng with my code, the size of the password field in the database was too small.
Obviously the SHA() function creates the encryption up to more than 20 characters long, and i had set my MySQL database to save only 20 of those characters... haha oops.
So when you came back to SELECT * FROM members WHERE password = SHA('test'), that was trying to find a password field with over 20 characters long, and none existed.
Anyway, there was nothing wrong with my code, just the actual database.
Cheers for all your help people.