inosent Posted February 1, 2013 Share Posted February 1, 2013 I have a MySql DB located on server_a.com, properly configured, and it is accessed by a set of php pages in a folder, server_a.com/data_entry server access comes through this php page as an include at the top of each php page in the folder: <?php $user_name="user_name"; $password="db_pass"; $database="data"; $hostname = 'data.db.1234567.hostedresource.com'; mysql_connect($hostname,$user_name,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> the trick is (i think, and i cant firgure this out) in how to revise: $hostname = 'data.db.1234567.hostedresource.com'; to somehow point to it from the remote server, that has the exact same set of php pages in a folder similarly named, i.e. server_b/data_entry fwiw, the MySql is located somewhere inside the godaddy universe (the site is hosted by godaddy), but the remote server is bluehost. any ideas greatly appreciated TIA! Quote Link to comment Share on other sites More sharing options...
requinix Posted February 1, 2013 Share Posted February 1, 2013 to somehow point to it from the remote server Point to what? From where? Quote Link to comment Share on other sites More sharing options...
inosent Posted February 1, 2013 Author Share Posted February 1, 2013 hi, thanks for the reply ok, so long as all the php files are located on server A (the local server), data entry into the MySql works great. to access a MySql DB takes a user name, password, database name, and hostname, which in my case is this: $hostname = 'data.db.1234567.hostedresource.com'; in my case, the hostname looks like it is also showing the location of the MySql DB. so, in other words, this line of code, $hostname = 'data.db.1234567.hostedresource.com';, 'points to' the location of the MySql DB referenced. When this line of code is read from a file located on server_a in the data_entry folder, i have no problems accessing the DB. However, if i upload the exact same php files, with the exact same code, to a *different* server, or if it is easier to understand, a different *host*, if i try to access the MySql DB it wont work. i am guessing it has to do with this line of code: $hostname = 'data.db.1234567.hostedresource.com'; this works perfectly so long as the php file that uses that line of code is located on server_a.com but i want to access that same MySql DB from server_b.com the question is can that be done, and if so how to do it thanks again Quote Link to comment Share on other sites More sharing options...
requinix Posted February 1, 2013 Share Posted February 1, 2013 Could be the MySQL server does not allow connections (for that user/password/database) from anything but server_a. For testing only stick an or die(mysql_error()) after the mysql_connect() and the mysql_select_db() (instead of what you have now) calls so you can get an error message indicating why it's not working. Quote Link to comment 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.