MySQL Forums
Forum List  »  PHP

Access denied for user 'root'@'localhost' (using password: YES)
Posted by: Jawed Ali
Date: July 29, 2007 12:29PM

Hello,

When I am trying to connect to mysql database from php script I am getting following error.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in D:\tools\Apache2\htdocs\saz\admin\index.php on line 27

/* PHP code start*/
//Set database connection
$server = mysql_connect($host, $username, $password) or die("Can't find the Database Server");
// Select the database now:
$connection = mysql_select_db($database, $server) or die("Invalid Database schema");
$sql = "SELECT * FROM users WHERE userID = '$userID' AND password = '$password'";
$results = mysql_query($sql);
if ($user = mysql_fetch_array($results))
{
echo $user['name'];
}
mysql_close($server);
/* PHP code ended */


All the required information provided to database server are correct. I using following environment:
apache 2.0.53,
mysql 4.1.22-community-nt,
PHP 5.1.1

Please guide me how to fix the issue.

Thank you,

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.