adamjones Posted October 24, 2008 Share Posted October 24, 2008 Hi. Just wondering how I would go around connecting to a database on a different server? <?php $host="localhost"; $username="username"; $password="password"; $db_name="database"; ?> Would I just change it to; <?php $host="mywebaddress.com"; $username="username"; $password="password"; $db_name="database"; ?> Or is it more complex? Sorry about the silly question! Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/ Share on other sites More sharing options...
wildteen88 Posted October 24, 2008 Share Posted October 24, 2008 Yes just specify the domain or the IP address for the mysql server you're wanting to connect to. Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674076 Share on other sites More sharing options...
adamjones Posted October 24, 2008 Author Share Posted October 24, 2008 Does this work if you're using shared hosting? Just tried and got this error; Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'wowdream_domaine'@'atlantic.lc-hosting.com' (using password: YES) in /home/visionop/public_html/test.php on line 8 cannot connect ...Must I have dedicated hosting? Regards. Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674099 Share on other sites More sharing options...
.josh Posted October 24, 2008 Share Posted October 24, 2008 the target host needs to be set to allow outside connections, as well. You have to specify the allowed host's IP through cpanel or on command line or wherever. Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674107 Share on other sites More sharing options...
adamjones Posted October 24, 2008 Author Share Posted October 24, 2008 Ok. I'm using cPanel 10 - How do I do this? Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674108 Share on other sites More sharing options...
.josh Posted October 24, 2008 Share Posted October 24, 2008 go down to database section click on remote mysql and fill in the blank Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674110 Share on other sites More sharing options...
adamjones Posted October 24, 2008 Author Share Posted October 24, 2008 Thanks! [: Quote Link to comment https://forums.phpfreaks.com/topic/130013-solved-quick-question-about-database-connection/#findComment-674112 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.