Page 1 of 1

database connection

Posted: Wed Jul 14, 2004 9:47 am
by gurjit
hi all,

i'm trying to connect to a database on server 2 and my website is on server 1.

lets say
server 2 ip is 163.1.209.3
server 1 ip is 189.4.689.7

in my db connections file on server 1 i do this

Code: Select all

<?php
$hostname = "163.1.209.3";
$database = "mydb";
$username = "us";
$password = "pa";
$my_conn = mysql_connect($hostname, $username, $password) or die(mysql_error());

mysql_select_db($database,$my_conn);

?>
what am i doing wrong?

Posted: Wed Jul 14, 2004 9:53 am
by redmonkey
Does the server allow remote connections?

Posted: Wed Jul 14, 2004 12:01 pm
by pickle
Ya, your code is fine. Check if the server allows remote connections - like ~redmonkey said. Also, make sure the user you are using can connect to that specific database from that specific IP. I know my servers only allow connections from localhost and explicitely stated IP's, never '%'.