cannot connect with database

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
umang40
Forum Newbie
Posts: 8
Joined: Wed May 20, 2009 7:31 am

cannot connect with database

Post by umang40 »

//first.html//

<html>

<body>
<form action="one.php" method="post">
First name: <input type="text" name="FirstName" size="20" /><br />
Last name: <input type="password" name="password" size="20" /><br />
<input type="submit" value="Submit" />
</form>

</body>
</html>


//one.php//
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{

die('Could not connect: ' . mysql_error());
}
mysql_select_db("db1", $con);
$sql="INSERT INTO info (username,password)
VALUES
('$_POST[FirstName]','$_POST[password]')";
header("Location: second.html");
?>

//there is an error when run in browser-:
Could not connect: Access denied for user 'root'@'localhost' (using password: NO)//
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: cannot connect with database

Post by Chalks »

make sure you have the right username, password and permissions...
Post Reply