The error clearly shows that the database hostname and username are incorrect. Maybe the password is too, but we can’t tell.
Please make sure to use the right connection settings for your database. You can find them on the MySQL Databases pages for your account in the client area.
Of course the database works in phpMyAdmin. That’s because phpMyAdmin uses the correct connection settings. Your code very clearly does not.
In case it’s not clear:
This tells me you are using the database hostname 127.0.0.1, username fighter and database name fighter. All of those cannot be correct. Please check the client area for the right settings to use.