News:

The "Support Requests" forum is now viewable by guests.

Main Menu

Access denied for user 'apache'@'localhost'

Started by wstreet, March 26, 2006, 07:44:58 PM

Previous topic - Next topic

wstreet

Trouble with connecting to mysql.

I am getting the following 2 messages:

Warning: mysql() [function.mysql]: Access denied for user 'apache'@'localhost' (using password: NO)

Warning: mysql() [function.mysql]: A link to the server could not be established

Any suggestions.

webzone (archived)

You need to use mysql_connect() to connect to the database server first. If you are already using it, verify that you are providing your database username and password properly. It should look like:

mysql_connect('localhost', 'my-db-username', 'my-db-password');

Note: You need to create a database before using it, if you have not already done so. You can add a database to your account using your account control panel.

wstreet

Thanks for the feedback...

I have setup my database in my control panel. I've got my db_name, db_username and db_password.

However, I am not sure how to make sure that I am using mysql_connect() to connect to the database server first, as you suggested.

This is the mysql.lib file that I have installed on the web server:
<?
  $connected = false;
  function c()
  {
      global $db_host, $db_login, $db_pswd;

      $db = @mysql_connect($db_host, $db_login, $db_pswd);
      $connected = true;
      return $db;
  }

function q($q_str)
{
    global $db_name, $connected;
    if(!$connected)
    {
       c();
    }

    $r = mysql($db_name, $q_str);
    return $r;
}

function d($db)
{
    @mysql_close($db);
}

function e($r)
{
  if(@mysql_numrows($r))
   return 0;
  else return 1;
}

function f($r){
  return @mysql_fetch_array($r);
}

function nr($r){
  return @mysql_num_rows($r);
}
?>

Ben

Do you have a config file? If so, look for
$db_host = "localhost"
$db_login = DATABASE USERNAME
$db_pswd = DATABASE PASSWORD
$db_name = DATABASE NAME

There's gotta be a config file somewhere.
--Ben
Ben@freepgs.com