connect access denied error when trying to access remote database

I'm completely new to php and mySQL and 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 "
"; }

mysql_close($con);

The database, table, username and password names are all correct (Ive 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)**

Any ideas on the problem? TIA, Matt


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.

链接地址: http://www.djcxy.com/p/21868.html

上一篇: 使用HTTP POST方法通过php更新mysql数据库

下一篇: 尝试访问远程数据库时连接访问被拒绝错误