Skip navigation links

MySQL Forums :: PHP :: Access denied for user 'root'@'localhost' (using password: YES)


Advanced Search

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


Subject Written By Posted
Access denied for user 'root'@'localhost' (using password: YES) Jawed Ali 07/29/2007 12:29PM
Re: Access denied for user 'root'@'localhost' (using password: YES) Me You 08/01/2007 04:41PM
Re: Access denied for user 'root'@'localhost' (using password: YES) ratlewhisk ratlewhisk 09/24/2007 04:57AM
Re: Access denied for user 'root'@'localhost' (using password: YES) Chowdary VAR 09/03/2007 01:08AM
Re: Access denied for user 'root'@'localhost' (using password: YES) mitch talmadge 07/19/2008 12:48PM
Re: Access denied for user 'root'@'localhost' (using password: YES) chris stefanich 07/30/2008 07:58AM
Re: Access denied for user 'root'@'localhost' (using password: YES) Gisha James 09/11/2008 09:17PM
Re: Access denied for user 'root'@'localhost' (using password: YES) Martin Rudolfson 10/05/2008 12:15AM


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.