Reputation: 141
When i upload db.php page to the server it's say
Warning: mysql_connect() [function.mysql-connect]: Access denied for user
'somename'@'somenumber' (using password: YES) in /home/somename/public_html/db/db.php on
line 2 Could not connect to Server: Access denied for user 'somename'@'somenumber'
(using password: YES)
Why it's say ?
db.php code:
<?php
$db = mysql_connect('www.mysite.com', 'somename', 'password');
if (!$db)
{
die('Could not connect to Server: ' . mysql_error());
}
if (!mysql_select_db("datbasename",$db))
{
die('Could not connect to DataBase : ' . mysql_error());
}
?>
Upvotes: 0
Views: 106
Reputation: 1373
In mysql_connect('www.mysite.com', 'somename', 'password');
you will need to give your database hostname, not your site hostname.
Check with your hosting provider for database hostname.
It is localhost if database is on same server/machine.
Upvotes: 0
Reputation: 29462
In mysql it' not only username and password, but also host that matters while connecting.
Your username and password may work for localhost
but to connect from host1.someserver.com
you will need different credentials.
In your case @'somenumber'
may be IP address that you are connecting from, ensure that username you are using is allowed to connect from this IP.
Upvotes: 1
Reputation: 68476
Either the password is wrong or you don't have enough privileges for the user.
Try with username as "root" and password as "" and see if it works, otherwise you are doing it wrong.
Upvotes: 0
Reputation: 31637
line 2 Could not connect to Server: Access denied for user 'somename'@'somenumber'
says CLEARLY, access is denied for the user somename
. Get privileges to get connected first...
Good Luck!!!
Upvotes: 0
Reputation: 41934
You cannot access to the database because your usename + password aren't correct.
Upvotes: 0