Forum Moderators: coopster
Is there a way I can access the databases on the server that doesn`t have them from the one that does? I read a previous post about ODBC, but I`m not sure what that is exactly.
Its no big deal, but it would make things easier if I could.
Thank you!
ODBC (Open Database Connectivity) is an operating system and database independent communication API that allows a client application (productivity tool, other database, web page, custom application, etc.) to communicate via standards-based function calls to a back end database without relying on that vendor's proprietary communication protocols.Reference:
ODBC and PHP HOWTO:
h**p://www.iodbc.org/index.php?page=languages/php/index
I`m using this syntax to connect on the server that has no database to the server that has.
$mysql_database = "databasename";$db = mysql_connect("209.****.xxx.xxx","username","password") or die(mysql_error());
mysql_select_db($mysql_database,$db) or die(mysql_error());
But I get an ACCESS IS DENIED message. Is there something I`m missing. I tried some of the syntax from those other posts coopster, but got no joy.
Any ideas?
[edited by: jatar_k at 10:51 pm (utc) on Jan. 25, 2004]
[edit reason] obfuscated ip [/edit]
If you have CPanel on that host, go to the MySQL management page. At the bottom is an Access Hosts input field. Place the IP address of the web host in that field and add it. This should fix the problem.
Just as a follow up, I contacted my hosting company and it is possible as long as I have a static IP address. Which I don`t have. Thats ok, its no biggie, just something I was curious about.
You can't use your domain name? Is your web host on a dynamic IP address?
If your web site is on a shared server, it is certainly possible to do what you want. I can even connect to a MySQL server on a dynamic IP by using dyndns.org.
What you do need to is to determine what name the reverse DNS lookup resolves to. It probably isn't your domain name, but the name of the shared server. The way to determine what the name is, is to attempt to connect to the MySQL server and print the error. Use the standard connect code like this:
mysql_connect ($host, $user, $pass)) or die ('I cannot connect to the database because: ' . mysql_error();
Use the <some domain name> as the access host on the MySQL server.
In my particular case I have a machine running MySQL connected via a dynamic IP DSL line. I have an account at dyndns.org for that DSL line that provides DNS lookup. I also have a public web server where the PHP code runs. I then access the public web server from yet another computer.
All these linkages work just fine. What you are describing should be even easier as both servers are public servers with static IP addresses.
It can be done.