Page 1 of 1

Connecting to MySQL database

Posted: Tue Dec 01, 2009 11:23 pm
by bob09
Hello All,

I have a problem. I am trying to connect to a MySQL database. I have created a HTML login screen for a person (which will be me or my partner) to enter their username and password.

Here's the HTML code:

Code: Select all

 
 <html>
<head>
<title>Login screen for ITCS 6160</title>
</head>
<body>
<form name="login_info" action="dbConfig.php" method="post">
Username: <input type="text" name="username">
<br>
Password: <input type="password" name="password">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
 
Once the person press the submit button, I want to connect to the database.

Here's the dbConfig.php code

Code: Select all

 
<?php
 
$conn = mysql_connect("localhost","falldb_TX","austin");
 
mysql_select_db("falldb_TX");
?>
 
Here is the error that I am getting:

Code: Select all

 
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'falldb_TX'@'localhost' (using password: YES) in C:\wamp\www\Project\dbConfig.php on line 3
 
I have been working on this for the past few days. I am using the WAMPSERVER which has apache, mysql, php. When I first started to solve the problem, I learned that I had to reconfigure my WAMPSERVER which I did (originally I couldn't access myPHPAdmin on my laptop it was saying that it was forbidden, after reconfiguring the file I can access it).

Anyway the database is stored on another website, through my school website which also has a PHPMyAdmin, but the server says: "Localhost using a UNIX socket" and the user is, "falldb_TX@localhost", while my PHPMyAdmin says "Localhost via TCP/IP" and the user for my server is saying: "root@localhost" for the username and password in the PHP code, I am putting the username and password that I use to connect to the database.

I am REALLY confused, and if someone can help that would be great.

Re: Connecting to MySQL database

Posted: Tue Dec 01, 2009 11:31 pm
by mrvijayakumar
Username Or password might be wrong, try different username and password. Default user name and password is "root" and "" [No password required]. Try this.

Re: Connecting to MySQL database

Posted: Tue Dec 01, 2009 11:32 pm
by bob09
It seems that I have found a solution! I took the password part out and left it blank and now it works!

Thanks to everyone who read this.

Re: Connecting to MySQL database

Posted: Tue Dec 01, 2009 11:36 pm
by John Cartwright
bob09 wrote:It seems that I have found a solution! I took the password part out and left it blank and now it works!

Thanks to everyone who read this.
This means you do not have a password set. I would highly recommend you set one!