Would anyone know how to handle MsSQL errors in PHP?

I'm using PHP version 4, build 8/23/2004. I know, I need to update, but haven't had the time.

On my login form, if someone where to try to inject SQL code or if a person accidentally entered in nonvalid characters, it shows an error. But I just want to show as though the username or password was entered wrong.

I've tried a try/catch block, but that just gave me a syntax error. Any ideas would be greatly appreciated. Thanks.