0

I am tring to connect mySQL db hosted on a live server the line of code to connect db is

mysql_connect("example.com", "webwork_odesk1", "xxxxxxxx" , "webwork1_odesk") or die("Couldn't make connection.");

The username and password are correct but the error displaying in browser is

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'webwork_odesk1'@'119.154.3.131' (using password: YES) in C:\xampp\htdocs\project\index.php on line 4

Couldn't make connection.

How I can fix this problem

Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
Muhammad Usman
  • 10,426
  • 22
  • 72
  • 107
  • 1
    I hope those aren't your real login details. – andrewsi Nov 12 '12 at 20:27
  • these aren't the real. but I am using the real one – Muhammad Usman Nov 12 '12 at 20:27
  • 3
    Please don't use the `mysql_*` functions as they are in the [deprecation process](http://news.php.net/php.internals/53799). Use [MySQLi](http://php.net/manual/en/book.mysqli.php) or [PDO](http://php.net/manual/en/book.pdo.php) instead and [be a better PHP Developer](http://jason.pureconcepts.net/2012/08/better-php-developer/). – Jason McCreary Nov 12 '12 at 20:28
  • Perhaps check that your mysql server and mysql user allows external connections, perhaps its also bound to only listen to internal loopback connection, `127.0.0.1/localhost` – Lawrence Cherone Nov 12 '12 at 20:32

2 Answers2

1

It probably has to do with the MySql Server permissions. Probably it doesn't accept connections from outside. You can shortly test this by uploading the script and using localhost to connect to the database server.

Andrei Hardau
  • 361
  • 2
  • 4
0

See this similar thread.

Like I said there, "Access denied for user 'webwork_odesk1'@'119.154.3.131' (using password: YES)"-messages come from two things - either hostname/username/password/database is wrong or the user doesn't have the required permissions. Check that user has the right permissions.

Community
  • 1
  • 1
eis
  • 51,991
  • 13
  • 150
  • 199