inosent Posted May 27, 2010 Share Posted May 27, 2010 i have a working set of php pages that finally do what i want them to. however, the database is located at my site, but i need to host the web pages on the company site, and i am not able to create a mysql db there, but the site is php enabled and i have permissioned this particular site to access the db at my site using the cPanel. this is my dbinfo.inc.php file <?php $username="user"; $password="pass"; $database="dbname"; ?> the connection line in every file, which works when the pages are hosted locally, is mysql_connect(localhost,$username,$password); so obviously the term 'localhost' wont work. at my site in the cPanel i see this: "Remote Database Access Hosts You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site. Add Access Host Host (% wildcard is allowed):" and i added the site name where i want the pages to be in these various ways: thesite.com www.thesite.com %thesite.com %www.thesite.com i have been inserting these where 'localhost' is, but i cannot make a connection. any thoughts on this would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/ Share on other sites More sharing options...
teamatomic Posted May 27, 2010 Share Posted May 27, 2010 mysql_connect('thesite.com',$username,$password); should work HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/#findComment-1063921 Share on other sites More sharing options...
trq Posted May 27, 2010 Share Posted May 27, 2010 The part in cPanel that asks for a remote host would need to be the hostname (or ip address) of the site you wish to allow access to your database. The part in your connection however would need to be the name of the server hosting the database. Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/#findComment-1063922 Share on other sites More sharing options...
inosent Posted May 27, 2010 Author Share Posted May 27, 2010 yeah, this is the sort of thing that is hard to make work because i dont have control over the server i want the pages on my site is 'mysite.com' and the site where i want the pages located is 'thesite.com' i uploaded the pages to thesite.com and changed localhost to 'mysite.com' with single and double quotes, even tried 'www.mysite.com' but no connection. probably something about 'thesite.com' that blocks this sort of thing? is that possible? Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/#findComment-1063927 Share on other sites More sharing options...
teamatomic Posted May 27, 2010 Share Posted May 27, 2010 Then if you have added thesite.com via the cpanel at mysite.com for remote access you should use mysite.com as the replacement to localhost in the code on thesite.com. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/#findComment-1063945 Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2010 Share Posted May 27, 2010 Ummm... The part in your connection however would need to be the name of the server hosting the database. Is your database server hosted on the mysite.com IP address or does it actually have some other host name or IP address? Quote Link to comment https://forums.phpfreaks.com/topic/203042-connect-to-remote-host/#findComment-1063947 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.