By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

Help regarding connection

P: 13
I was trying to create a website that enables the users to Input something in it, like user info. but it always gives an error whenever I try to test submit the inputted data's into the database.
'Could not Connect: Access denied for user 'smdg'@'localhost' (using password: YES)'


Expand|Select|Wrap|Line Numbers
  1. define('DB_NAME', 'testdb');
  2. define('DB_USER', 'smdg');
  3. define('DB_PASSWORD','samplepass');
  4. define('DB_HOST', 'localhost');
  6. $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, '3306');

Expand|Select|Wrap|Line Numbers
  1. /* Authentication type and info */
  2. $cfg['Servers'][$i]['auth_type'] = 'cookie';
  3. $cfg['Servers'][$i]['user'] = 'smdg';
  4. $cfg['Servers'][$i]['password'] = '';
  5. $cfg['Servers'][$i]['extension'] = 'mysqli';
  6. $cfg['Servers'][$i]['AllowNoPassword'] = true;
  7. $cfg['Lang'] = '';
  9. /* Bind to the localhost ipv4 address and tcp */
  10. $cfg['Servers'][$i]['host'] = '';
  11. $cfg['Servers'][$i]['connect_type'] = 'tcp';
anyone who can point out what I did wrong or what I'm missing?
Sep 9 '15 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 100+
P: 589
Are you able to connect from the command line using the same credentials?

Take the port number out of the connect statement.

Don't use the mysql_ functions, they are depreciated. Instead, you should be using mysqli_ or PDO.
Sep 9 '15 #2

P: 13
yes I am able to connect, I double checked it.

take note that my problem is i cant insert any info to the database by connecting through the internet. I can view the Form in which the Infos will be inputted but when I try to press 'submit' button it always gives me an error saying 'Access denied for user "user@localhost" blah blah. like that, I've consulted some friends and they said that it should work but it doesn't
Sep 10 '15 #3

Expert Mod 100+
P: 589
Which of those 2 code snippets are you using when connecting to the database?

The first one is using the mysql_connect() function incorrectly and should generate a syntax error. The second one doesn't show the connect statement but implies that it will be using the mysqli_connect() function.

There is also a discrepancy with the configured password. Since you're receiving an access denied error instead of a syntax error, I'll assume you're using the second code snippet when connecting, which is passing an empty string as the password instead of the password configured in the other snippet. Have you tried setting the password?

Try changing:
Expand|Select|Wrap|Line Numbers
  1. $cfg['Servers'][$i]['password'] = '';
Expand|Select|Wrap|Line Numbers
  1. $cfg['Servers'][$i]['password'] = 'samplepass';
Make sure you put in the real password.
Sep 10 '15 #4

P: 13
still the same. no improvement, maybe ill just try a different approach on this. thanks for your help though. cheers
Sep 15 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.