Hey guys, I’m just starting out with MySQL and PHP and have a question.
So I went to PHPmyAdmin and created a database. In that data base i created a Table.
Now I want to access the table with PHP and i use the following code:
<?php
$con = mysql_connect("localhost","username_of_my_database","password_of_my_database");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
However, I get this error:
Warning: mysql_connect()
[function.mysql-connect]: Access
denied for user
‘username_of_my_database’@’localhost’
(using password: YES) in
/home/user_of_my_database/public_html/mywebsite.com/facebook/home.php
on line 3 Could not connect: Access
denied for user
‘username_of_my_database’@’localhost’
(using password: YES)
So the log in data are wrong. My question is: How do you get the right log in data? What do i have to fill in instead of what i did?
Thanks a lot for your help!
So what should i use: My username is: javaaa, my database is called: new year, which make for javaaa_newyear? and the password was made when making the new year database. And within the new year database there is a table called: party.
One of the parameters must be incorrect.
Remember that ideally your webserver and database should be on different servers. If this is the case then “localhost” will not be the correct host for your database and this will mean that you are logging into the wrong database – try to find out the correct IP address or hostname for your database server (not your web server) and use that instead.
If the hostname is correct then it must be an incorrect user name or password.