I am layman to this so please have patience. My programmer abandoned me, so i am trying to do this myself.

I am getting this error when i try to access a php file: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'rarehiph_main'@'localhost' (using password: YES) in /home/rarehiph/public_html/includes/functions/database.php on line 21
Unable to connect to database server!

Here is the includes line 21: $$link = mysql_connect($server, $username, $password);

What do i need to do to make this work? I just created user 'main' in the database, but still no go. Again, I have never done this, so this must be DB101 to you lol! Thanks to all in advance.

    You need to find out what the values are for the three parameters: $server, $username, and $password. Then you need to find out if each of them is correct. For something quick and dirty (that you do NOT want to leave in your production code!):

    $link = mysql_connect($server, $username, $password);
    if($link == false) {
      die("<pre>Connect failed: '$server', '$username', '$password'\n".mysql_error());
    }
    

      Welcome to PHPBuilder. We may be able to offer some assistance, but caveat emptor and all that ;-)

      Access denied for user 'rarehiph_main'@'localhost' (using password: YES)

      This is a simple DB server login failure.

      The user shouldn't be "main", according to the message, but instead "rarehiph_main". This is likely the problem.

      It looks as if $server is set to "localhost", which is appropriate is the DB is on the server running your "database.php" script.

      So, that being said, if all else is correct, the password is wrong. Look for "$password" above line 21 and make sure it's set to the correct password for the user.

        NogDog;11034655 wrote:

        You need to find out what the values are for the three parameters: $server, $username, and $password. Then you need to find out if each of them is correct. For something quick and dirty (that you do NOT want to leave in your production code!):

        $link = mysql_connect($server, $username, $password);
        if($link == false) {
          die("<pre>Connect failed: '$server', '$username', '$password'\n".mysql_error());
        }
        

        Do it put this in database.php to check?

          here is what i put in: $link = mysql_connect('50-62-213-80', 'rarehiph_main', 'password');

          I went to msql databases in cpanel to make sure the password is correct and now i get this error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'rarehiph_main'@'ip-50-62-213-80.ip.secureserver.net' (using password: YES) in /home/rarehiph/public_html/includes/functions/database.php on line 21
          Unable to connect to database server!

            If that is supposed to be an IP address for the first parameter, then the numbers should be separated with dots (periods, full stops, whatever), not hyphens.

            Also, I hope I'm safe in assuming you're not showing us the real password here? (If you are, you'll want to change it soon!)

              Yes, the ip is separated by dots (the hyphens was inserted by the error message) and no, that is not the real password.

                So does the user 'rarehiph_main'@'50.62.213.80' actually have credentials on that server, and did you use the correct password for this user?

                This is still a simple credentials issue. (Well, I guess 'simple' is relative, but it's not about PHP)....

                  dalecosp;11034673 wrote:

                  So does the user 'rarehiph_main'@'50.62.213.80' actually have credentials on that server, and did you use the correct password for this user?

                  ... and does the 'rarehiph_main' user have permissions to connect from the host that is running your PHP code?

                    dalecosp;11034673 wrote:

                    So does the user 'rarehiph_main'@'50.62.213.80' actually have credentials on that server,

                    The ip shown there is the address of the server, and most likely not rarehiph.

                    So it's not 'rarehiph_main'@'50.62.213.80' who needs access. It's 'rarehiph_main'@'whatever-your-ip-is'. Without ip restrictions, it would be @'%'

                      I found someone to assist me, but he is MIA now. Question, what file usually would contain this code and/or where should i look? Includes?

                      <?php

                      //require_once('/home/rarehiph/public_html/20100809/librariesets.php');
                      //require_once('/home/rarehiph/public_html/librariesets.php');
                      // modify these constants to fit your environment
                      if (!defined("DB_SERVER")) define("DB_SERVER", "localhost");
                      if (!defined("DB_NAME")) define("DB_NAME", "managed_ticket");
                      if (!defined("DB_USER")) define ("DB_USER", "managed_ticket");
                      if (!defined("DB_PASSWORD")) define ("DB_PASSWORD", "xxxx");

                      // some external constants to controle the output
                      define("QS_VAR", "page"); // the variable name inside the query string (don't use this name inside other links)
                      define("NUM_ROWS", 5); // the number of records on each page
                      define("STR_FWD", "&gt;&gt;"); // the string is used for a link (step forward)
                      define("STR_BWD", "&lt;&lt;"); // the string is used for a link (step backward)
                      define("NUM_LINKS", 5); // the number of links inside the navigation (the default value)
                      ?>

                        Write a Reply...