简体   繁体   中英

mysql_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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM