I can not connect to mysql

It would if you actually read it. You are using localhost, which is incorrect.

The rest of the construct() function looks incorrect as well. Please make sure you are getting the information from the client area / control panel, not just making it up.