trying to allow site1 to access a db on site2. site2 has site1 on the allow list for remote access.
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$host="host.com"; // Host name
$username="user"; // Mysql username
$password="pw"; // Mysql password
$db_name="mydb"; // Database name
$tbl_name="userCred"; // Table name
// Connect to server and select databse.
$link=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
i am getting the following error:
” Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘user’@’ans70.midphase.com’ (using password: YES) in /home/site/public_html/subsite/remote.php on line 13″
The MySql user must have the correct host set. If the user is set as localhost then that user can only connect from localhost and not from the remote machine where your PHP code is running from.
This is covered more here http://dev.mysql.com/doc/refman/5.1/en/adding-users.html