I have an application written in C# and it does connect with the database.
Here's the error I'm getting:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in (php file) on line 15
Could not connect: Access denied for user 'username'@'localhost' (using password: YES)
Here is my code:
$mysql = mysql_connect("localhost", "username", "password");
if (!$mysql) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
I got this example from:
http://php.net/manual/en/function.mysql-connect.php
What am I doing wrong?
Answer
Your username in mysql in probably not "username", as your password is not "password". Please change it to something like
$mysql = mysql_connect("localhost", $username, $password);
where $username
is variable with your db username and $password
is variable with your db password.
Also it would be good thing to use MySQLi
instead of mysql_
functions.
No comments:
Post a Comment