Mysql error message 1062 in php script

The 1062 error is what is supposed to happen (with reference to your other topic) when a duplicate value is entered to a unique column.
As stated, use a try/catch to catch the error and deal with it.
This is a case where you want an error, so you can use it in validation.