0

I have this array that store the connection info and i want to use it when perform the query

$dblist = array();

$dblist[] = array(
        'host'=>'192.168.1.20',
        'username'=>'root',
        'password'=>'root1',
        'database'=>'unsubscribe_1',
        'table'=>'subscribers'
        );

$dblist[] = array(
        'host'=>'192.168.1.5',
        'username'=>'root',
        'password'=>'root2',
        'database'=>'unsubscribe_test',
        'table'=>'subscribers2'
        );


foreach($dblist as $list)
{
$host = $list['host'];
$username = $list['username'];
$password = $list['password'];
$db = $list['database'];
$tb = $list['table'];

$conn1 = mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($db,$conn1) or die(mysql_error());

$sql = "select * from $db";
$query = mysql_query($sql,$conn1) or die(mysql_error());    
}

The problem is i keep getting this error "Host '192.168.1.5' is not allowed to connect to this MySQL server"

What is the problem here?

4
  • 1
    Host '192.168.1.5' is not allowed to connect to this MySQL server Commented Jan 18, 2011 at 8:55
  • I am pretty sure it is allowed because i am working in that 192.168.1.5 (localhost) Commented Jan 18, 2011 at 8:58
  • What happens if you swap the order of the array so 192.168.1.5 is connected first? Commented Jan 18, 2011 at 8:59
  • You cannot be sure! Just because you're watching this error message with your own eyes! So, the only thing you can be sure of - it's that your host isn't allowed! The only thing you really need is to trust your eyes, not fantasies Commented Jan 18, 2011 at 9:11

1 Answer 1

1

I assume Host '192.168.1.5' is your local machine and you encounter this error when trying to connect to Host .20, You need to enable remote access for Host .5 on Host .20's MySQl server.

HowTo

-michael

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.