By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

connecting to remote database

tolkienarda
100+
P: 316
hi all

i would like to connect to a database on a different domain. and i was wondering what i have to change on the regular database connection code to make it work.
example i need to print info stored on my company's server on several of our client's pages.

[PHP]
$host="localhost";
$db_user="username";
$db_password="password";
$database="databasename";
$var = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
[/PHP]

thanks for any input
Feb 21 '07 #1
Share this Question
Share on Google+
4 Replies


Motoma
Expert 2.5K+
P: 3,235
You will need to change your host to a fully qualified domain name or IP address.
You will also need to make sure your database is accessible from the internet.
Feb 21 '07 #2

tolkienarda
100+
P: 316
is having my database accessable a php setting i can change in php.ini or is it somthing on the mysql side.

and will the domain like is shown below work

[PHP]
$host="http://www.nextstep-designsolutions.com";
$db_user="username";
$db_password="password";
$database="databasename";
$var = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
[/PHP]

thanks for your help

eric
Feb 21 '07 #3

Motoma
Expert 2.5K+
P: 3,235
is having my database accessable a php setting i can change in php.ini or is it somthing on the mysql side.

and will the domain like is shown below work

[PHP]
$host="http://www.nextstep-designsolutions.com";
$db_user="username";
$db_password="password";
$database="databasename";
$var = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
[/PHP]

thanks for your help

eric
Having it accessible to the outside means having firewall and port forwarding set up correctly.
The host is fine except for the http://
Feb 21 '07 #4

tolkienarda
100+
P: 316
ok thanks

eric
Feb 21 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.