Help regarding connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lgoddgreat
    New Member
    • Jun 2015
    • 13

    Help regarding connection

    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'@'localho st' (using password: YES)'

    connection:

    Code:
    define('DB_NAME', 'testdb');
    define('DB_USER', 'smdg');
    define('DB_PASSWORD','samplepass');
    define('DB_HOST', 'localhost');
    
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, '3306');
    config.inc.php

    Code:
    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'smdg';
    $cfg['Servers'][$i]['password'] = '';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    $cfg['Lang'] = '';
    
    /* Bind to the localhost ipv4 address and tcp */
    $cfg['Servers'][$i]['host'] = '127.0.0.1';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    anyone who can point out what I did wrong or what I'm missing?
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    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.
    Last edited by RonB; Sep 9 '15, 03:15 PM.

    Comment

    • lgoddgreat
      New Member
      • Jun 2015
      • 13

      #3
      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

      Comment

      • RonB
        Recognized Expert Contributor
        • Jun 2009
        • 589

        #4
        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:
        Code:
        $cfg['Servers'][$i]['password'] = '';
        To:
        Code:
        $cfg['Servers'][$i]['password'] = 'samplepass';
        Make sure you put in the real password.

        Comment

        • lgoddgreat
          New Member
          • Jun 2015
          • 13

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

          Comment

          Working...