MySql_connect Problem

Discussion in 'Databases' started by Dead Man, Oct 28, 2011.

  1. #1
    I have created a web & found below error. Please help where I am doing mistake??

    "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'atifh_ef'@'localhost' (using password: YES) in /home/atifh/public_html/admin/setting.php on line 198

    Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/atifh/public_html/admin/setting.php on line 199
    Access denied for user 'atifh_ef'@'localhost' (using password: YES)"

    "Setting.php" file attached for your reference
     

    Attached Files:

    Dead Man, Oct 28, 2011 IP
  2. 0ccul7

    0ccul7 Active Member

    Messages:
    275
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #2
    It's like the error message says. You are trying to connect to a MySQL database using invalid user information.

    You should create a new user and give him access to the database you are going to be using.
    Then you need to update your PHP code so that it uses the info for that user, rather then the old one.

    Also, keep in mind that using the root user in a PHP script is a HUGE security risk. You should always create a limited user to use in your websites.
     
    0ccul7, Oct 28, 2011 IP
  3. Dead Man

    Dead Man Active Member

    Messages:
    165
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Thanks I have tried many times by changes new MySql user+DB but same error. Anways look at lines 198 & 199 of script.

     
    Dead Man, Oct 28, 2011 IP
  4. Dead Man

    Dead Man Active Member

    Messages:
    165
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    88
    #4
    anyone can help please
     
    Dead Man, Oct 29, 2011 IP
  5. kellyphong

    kellyphong Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It is your mySQL user credentials issue; follow steps and let me know if you got any question or concern;
    1. Verify if your username and passwords are working; Try passing following command in your mySQL client (could be command prompt, SQLYog and a like)
      mysql --user atifh_ef --password atif -h localhost atifh_ef
      Code (markup):
      and observe what it returns
    2. If your username is not created then create one as follows;
      grant all on atifh_ef.* to atifh_ef@localhost IDENTIFIED BY 'atif'
      [*]Instead of [code]$db_connect = mysql_connect($db_host, $db_username, $db_password);
      Code (markup):
      write following
      $db_connect = mysql_connect($db_host, $db_username, $db_password) or die ("Database Connection Error: " .mysql_error());
      Code (markup):
    Best!
     
    kellyphong, Oct 31, 2011 IP