Double check your imei first, do not read it from box or back of phone. Dial the following into the phone:
* # 0 6 #
This way you know you have the actual IMEI, and be sure it is 15 numbers and leave out any / marks if there are any.
Now go to
www.lur.no
Enter your 15 digit IMEI exactly and get the master code they generate. If done correctly it really should work every time. If this doesn't work, you'll have to do a flash of the firmware on the phone (google will have info or just find me again), but this gets complicated.
If it is under warranty, you may try that if master code doesn't work this time.
Also have you tried the default codes? If it was never changed it should be 12345 or 0000 and some 5310 phones even came with the password as 9999. They used to also use the last 4 numbers of your phone number too.