garry27 Posted June 21, 2008 Share Posted June 21, 2008 Hi, I've just signed up to a web hosting service for the first time so I can transfer my website across from my old uni server and I'm having difficulty connecting. I'm signed up with webhostinguk and have created a db via phpadmin (called pubrunukDB). The help team told me I would need to enter the details I've entered into the mysql_connect parameters below to connect (to the mysql server, I think). Here's the code that I have edited from an existing script: $conn = mysql_connect('localhost', 'db_username_pwd', 'db_username'); $db_conn = mysql_select_db('pubrunukDB', $conn); Any help advice is appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
phpSensei Posted June 21, 2008 Share Posted June 21, 2008 edit: As Stephen said... gawd i'm blind. Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 21, 2008 Share Posted June 21, 2008 You connect with host, username, password. Not host, password, username. Quote Link to comment Share on other sites More sharing options...
garry27 Posted June 21, 2008 Author Share Posted June 21, 2008 I get: Could not connect: Access denied for user 'db_username'@'localhost' (using password: YES) Quote Link to comment Share on other sites More sharing options...
garry27 Posted June 21, 2008 Author Share Posted June 21, 2008 You connect with host, username, password. Not host, password, username. That's the way I have it in my code- I got it mixed up when I posted it here. Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 21, 2008 Share Posted June 21, 2008 Ah okay. Try creating a new user with all permissions for that database and connect to that user instead. Quote Link to comment Share on other sites More sharing options...
garry27 Posted June 21, 2008 Author Share Posted June 21, 2008 nopes. i get the same thing when i try with a different user. i've tried a false password and username and i get the same error message with this as well :-\ Quote Link to comment Share on other sites More sharing options...
garry27 Posted June 21, 2008 Author Share Posted June 21, 2008 i've set a new user with all new permssions and put the extended name as the password (and tried it for db as well) i.e. cpanelUsername_DBuserName and I get this new error message: Could not connect: Access denied for user 'cpanelUsername_DBuserName' to database 'cpanelUsername_DBname' Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 You need to use real connection details. Use the exact username and password you created the DB with. Quote Link to comment Share on other sites More sharing options...
garry27 Posted June 21, 2008 Author Share Posted June 21, 2008 I've contacted web hosting uk again and it turned out ito be a problem with them as it's working now using the syntax I decsribed- so thanks for your help guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.