Posted by:
mayankpd
(---.8.176.122.airtelbroadband.in)
I am getting this error when connecting with wamp inbuilt phpmyadmin mysql
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\addindex.php on line 2
Could not connect: Access denied for user 'root'@'localhost' (using password: YES)
here i was creating simple address book
created database addressbook in phpmyadmin
create table colleague(
id int(10),
firstName varchar(20),
lastName varchar(20),
telephone varchar(20),
email varchar940));
inseted data
2000 mayank pande 9897171214
mayankpd@gmail.com2001 ravi agarwal 9794452469
ravi.agarwal2@gmail.comPHP script
<<?php
$con = mysql_connect("localhost","root"," "
;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("addressBook", $con);
if (!$db_selected)
{
die ("Can\'t use addressBook: " . mysql_error());
}
$sql = "SELECT * FROM Person";
$result=mysql_query($sql,$con);
mysql_close($con);
?>
<!DOCTYPE html PUBLIC-"//w3c/dtd xhtml 1.0 Transitional //EN"
"[
www.w3.org];
<html xmlns="[
www.w3.org];
<head>
<title>Address Book</title>
</head>
<body>
<H2>Address Book</H2>
<table border="1" cellpadding="2" cellspacing="3" summary="Table holds colleague contact information">
<tr>
<th> ID</th>
<th> First Name</th>
<th> Last Name</th>
<th> Telephone</th>
<th> Email Address</th>
</tr>
<?php
//Loop through all table rows
while($row=mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id']."</td>";
echo "<td>" . $row['firstName']."</td>";
echo "<td>" . $row['lastName']."</td>";
echo "<td>" . $row['Telephone']."</td>";
echo "<td>" . $row['Email']."</td>";
echo"</tr>";
}
mysql_free_result($result);
mysql_close($con);
?>
</table>
</body>
</html>