Warning: mysql_query() [function.mysql-query]: Access denied for user...

Discussion in 'PHP' started by Marketer456, Apr 6, 2009.

  1. #1
    function Take_Action($decision,$id){
        
        $_SESSION['enemy']=My_Enemy_Is($id);
        $decline = strcmp($decision,"no");
        if ($decline==0){
        
          $con = mysql_connect(DB_HOST,"armiron_admin","admin");
          if (!$con){
            die('Could not connect: ' . mysql_error());
          }  
          mysql_select_db(DB, $con);
          $sql = mysql_query("DELETE FROM ".TABLE_CONTEST_ONE_ON_ONE." WHERE ID='".My_Enemy_ID_Is($enemy,$user)."'");
          
          mysql_close($con);
          
          echo "Declined <a href=Script_View_Challenge_Requests.php>View My Challenge Requests</a>";
         
          } else {
            
            header("Location: index_OneonOne.php?id=".$id."&challenge_back=yes");
          }
      }
    PHP:
    Getting an error saying
    
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'armiron'@'localhost' (using password: NO) in /home/armiron/public_html/Invisible_Functions.php on line 884
    
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/armiron/public_html/Invisible_Functions.php on line 884
    
    Warning: mysql_close(): 3 is not a valid MySQL-Link resource in /home/armiron/public_html/Invisible_Functions.php on line 886
    Declined View My Challenge Requests
    Code (markup):
    Now I made the database then i made the user gave him all the privileges and still does not work would you tell me how i could fix the problem?

    Thanks,
    - Avo
     
    Marketer456, Apr 6, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Well if you are on a cPanel server I would change DB_HOST

    to

    localhost

    Have fun

    edit: but usually the connnect file takes the form of localhost, databasename, username, password. Are you sure you entered all the other info correctly?
     
    Colbyt, Apr 6, 2009 IP
  3. amerigohosting

    amerigohosting Peon

    Messages:
    255
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it looks like it is the file:
    /home/armiron/public_html/Invisible_Functions.php line 884: it is using mysql user "armiron" vs the code snippet that you posted, which is using user "armiron_admin"
     
    amerigohosting, Apr 6, 2009 IP
  4. jackio

    jackio Banned

    Messages:
    490
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Seems that the user authentication is not correct, check login and pass again.
     
    jackio, Apr 6, 2009 IP
  5. Marketer456

    Marketer456 Peon

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    DB_HOST equals to localhost i used define for that and i checked the login info

    here is one question though the password and the username are the once for the user that i create using MySQL right it is not the password and the username for my account I really dont know what is causing this problem

    - Avo
     
    Marketer456, Apr 6, 2009 IP
  6. kusal

    kusal Peon

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I sometimes got this error when I didn't give enough privileges when I create the database.

    if you have cPanel goto your Mysql databases and click on the user name for your database and tick ALL PRIVILEGES checkbox and save
     
    kusal, Apr 6, 2009 IP
  7. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi

    Check the username and password is correct or not on your control panel.

    And also give the previlegies on your control panel.

    Regards
    Parthiban
     
    parthiphp, Apr 7, 2009 IP
  8. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #8
    Are you sure that your host is using localhost ( in most cases, you get a custom mysql host address ) ?
     
    ActiveFrost, Apr 7, 2009 IP