Jump to content

Transfering data from one server to another


Gruzin

Recommended Posts

Hi guys,
I want to transfer some data from one server to another, but:
1. URL file-access is disabled in the server configuration (I wanted to require php file from other server, but it's disabled)
2. I can connect to mysql db from one server to another

How can I transfer some data from one server to another? Is there any other way?

Thanks for any help,
George
Link to comment
Share on other sites

OK, I'll explain it:

I have a server A with mysql db and some data in it. And I have a server B (from wich I can not connect to server A's mysql db). I want some data (image name, apartment name and etc) to be displayed on server B. Is there any way to do this?

Thanks,
George
Link to comment
Share on other sites

[quote author=redbullmarky link=topic=122109.msg503197#msg503197 date=1168617978]
if it's in realtime, you could set up an XML API-type thing on server A (like RSS would work) and parse the info on server B...
[/quote]

YES!!! that's what I thought, but unfortunately I know nothing about it... can u please provide any example or any tutorial?

Thanks,
George
Link to comment
Share on other sites

well you dont really need to follow the strict rules of XML/RSS to get you started, so you could literally have somethign quite simple that just echo's out the fields

serverA.php
[code]
<?php
$id = $_GET['id'];

$query = "SELECT a,b,c FROM mytable WHERE id = '$id'";
$records = query stuff to get your records

foreach($records as $record)
{
  echo "{$record['a']},{$record['b']},{$record['c']}\n";
}
?>
[/code]

serverB.php
[code]
<?php
$contents = file_get_contents("http://serverA.com/serverA.php?id=2");

$records = explode("\n", $contents);

foreach($records as $record)
{
  list($a, $b, $c) = explode(',', $record);

  echo "a=$a, b=$b, c=$c <br />";
}
?>
[/code]

quick and dirty, and possibly many many better ways - but should give you an idea.

cheers
Link to comment
Share on other sites

yes, both php and both named after the server they'd go on. obviously how much you use this would depend on the nature of the data you're exchanging - for example, you wouldnt want to use something like this on a 'users' table, etc and you might still want to put something in place that would only allow access to serverA.php if called from serverB.php, and not direct access.

still, should set you on your way ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.