perhaps you have to let php display the error message, search for its configuration in php.ini.
If everything is done correctly (php works, mysql works) but still can't connect to mysql through php perhaps you should reinstall them (still not working? reinstall your linux. Its radical but it works sometime).
If you have better solution, tell us (people who reinstall linux to solve this problem).