Hi,
I am trying to do the following:
I would like 3 websites to "pull" data of the same MySql database on a 4th website / remote server.
How can I get my 3 websites to connect to that database on the 4th server in order to retrieve and display data from it?
The 4 sites are not hosted on the same server, hence a full path to the server in the connection string is not an option.
I can't see a way around it.
Can you help?
Thanks a lot,
vinny
retrieving data from remove server
Moderator: General Moderators
You could always have a small PHP page on the "4th server" which accesses the database, and then just use an include() or require() from the other websites to pull in the PHP file.
For example...
4th Server PHP
Other websites
It might work but I haven't tried it, it's just an idea.
You may need to change "localhost" in the mysql_connect() to your website address, something like "http://mySite.com".
For example...
4th Server PHP
Code: Select all
<?php
mysql_connect("localhost", "X", "X");
mysql_select_db("myDatabase");
$result = mysql_query($sql);
?>Code: Select all
<?php
$sql = "SELECT * FROM `myTable`";
include("http://mySite.com/phpScript.php");
// Should now have a variable called $result which holds the result
// of the mysql query $sql
?>You may need to change "localhost" in the mysql_connect() to your website address, something like "http://mySite.com".
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK