[function.mysql-connect]: Access denied for user

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
harshilshah
Forum Newbie
Posts: 16
Joined: Fri Jul 17, 2009 5:13 am

[function.mysql-connect]: Access denied for user

Post by harshilshah »

here's my code

Code: Select all

<?php
@session_start();
 // database code
$dbh=mysql_connect ("localhost", "root", "") or 
die('Cannot connect to the database because: ' . mysql_error());
  mysql_select_db ("wwwgodn_godnels");
  echo "Connection Successfull";
  
  
$sql="SELECT * FROM tblusers";
$result = mysql_query($sql) or die("Query failed with error: ".mysql_error());
 
echo "<table border=1><tr><td class=text>Username</td><td class=text>Password</td><td class=text>View</td><td class=text>Update</td></tr>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo "<tr><td class=text>".$row[0]."</td><td class=text>".$row[1]."</td><td><a href=view.php?txtusername=".$row[0]."&txtpassword=".$row[1].">View</a></td><td><a href=update1.php?txtusername=".$row[0].">Update</a></td></tr>";
}
echo "</table>";
mysql_free_result($result);
mysql_close($dbh);
 
?>
 

here's the error
i get

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'wwwgodn_godnel'@'localhost' (using password: YES) in C:\wamp\www\godnels\imagealbum\list1.php on line 12
Cannot connect to the database because: Access denied for user 'wwwgodn_godnel'@'localhost' (using password: YES)


Please someone help me figure out whats the problem with the code.
I haven't been able to debug the code yet.
any help would be greatful.
spider.nick
Forum Commoner
Posts: 72
Joined: Wed Jul 15, 2009 12:22 pm
Location: Overland Park, KS

Re: [function.mysql-connect]: Access denied for user

Post by spider.nick »

The error is stemming from an incorrect username and password combination in your mysql_connect() statement.

Nick
Post Reply