Reputation: 3606
I'm trying to connect to a remote database. Here's my code:-
php $con = mysql_connect("2toria.com","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("myTable", $con);
$result = mysql_query("SELECT * FROM Contestants");
while($row = mysql_fetch_array($result)) { echo $row['Name']; echo "<br />"; }
mysql_close($con);
The database, table, username and password names are all correct (I've changed them here for obvious reasons), but I'm getting the following error:-
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'bluechip6.ukhost4u.com' (using password: YES) in /home/toriaco/public_html/bigbro/index.php on line 9 Could not connect: Access denied for user 'username'@'bluechip6.ukhost4u.com' (using password: YES)**
Upvotes: 1
Views: 1794
Reputation: 7517
First possible reason:
I know antagonist (a Dutch hosting service) blocks all connections that are not from localhost
for security reasons, and I don't think they are the only ones. (So always connect to localhost, not a http://...
URL!)
Second possible reason:
The password/username is wrong.
Upvotes: 3