PHP: connect with external mysql database -
i want connect external database using php
. but, gives error
warning: mysql_connect(): can't connect mysql server on 'server_ip_address' (110) in /home/<username>/public_html/index.php on line 7 can't connect mysql server on 'server_ip_address' (110)
here code.
define("_config_db_host", "server_ip_address"); /* database host name */ define("_config_db_name", "database_name"); /* database name */ define("_config_db_user", "database_username"); /* database username */ define("_config_db_pass", "database_password"); /* database password */ $con = mysql_connect(_config_db_host,_config_db_user,_config_db_pass) or die(mysql_error()); mysql_select_db(_config_db_name,$con) or die(mysql_error());
i've added entry remote database access hosts
in host server
please guide me if i'm doing wrong.
make sure database_username
has access you host (the machine running script) has access database_name
on server_ip_address
.
when grant access on database use use username@host
form. here host
means host username
connecting from. keep localhost. becasue want connect user in localhost according mysql server. local host not mysql servers localhost. that's why host part needs changed.
Comments
Post a Comment