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 Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/ 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571003 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571005 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) Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571007 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571009 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571026 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 :-\ Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571036 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' Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571047 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571048 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. Link to comment https://forums.phpfreaks.com/topic/111252-newbie-to-db-connection/#findComment-571068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.