If the user name is still showing as 'apache' then it's almost certain that the variables your passing to mysql connect are not getting through.
If your sure the variables are populated, and the varnames have no spelling errors, then it's highly likley that the mysql user table does not have an entry in it for your user name connecting from local host, in which case you'll need to contact the server administrator to have the user name added.
Another common reason for not connecting is when the DB is on a different host, EG:
dbserver.mynetwork.com
if referenced as mysql_connect('dbserver','user','pass') then it will likley fail as the user name in the mysql users table will be 'user@dbserver.mynetwork.com'
Cheers
Shawty