Skip to main content
Inspiring
August 15, 2010
Question

Update two at the same time...

  • August 15, 2010
  • 1 reply
  • 939 views

How can I update two mysql databases (on two servers) at the same time. DO I need to give permission to send data?

E.g. The swf is in server A and I want to post data to 2 databases in server A and server B. But when I do it only updates in server A. Nothing goes to server B. How can I do this? Is this got to do with php? Please advice.

<?php

//SERVER A

$link = mysql_connect("localhost","abc","abc1");

mysql_select_db("my_db1");

$query = "INSERT INTO abc_db(subject, links) VALUES('$hsubjects','$link')";

$result = mysql_query($query);

//SERVER B

$links = mysql_connect("xxx.xxx.xx.xxx","xyz","xyz1");

mysql_select_db("my_db2");  

$query = "INSERT INTO notice_db(subject, links) VALUES('$hsubjects','$link')";

$result = mysql_query($query);

$sentOk = "The data has been added to the database.";

echo "sentOk=" . $sentOk;

?>

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 15, 2010

you almost certainly have a cross-domain security issue.

search for a php cross-domain proxy script.

Inspiring
August 15, 2010

Thank you. I found this php script. But where should I save the file on the server? on the root?

<?php

$post_data = $HTTP_RAW_POST_DATA;

$header[] = "Content-type: text/xml";

$header[] = "Content-length: ".strlen($post_data);

$ch = curl_init( $_GET['url'] );

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_TIMEOUT, 10);

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

if ( strlen($post_data)>0 ){

    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

}

$response = curl_exec($ch);    

$response_headers = curl_getinfo($ch);    

if (curl_errno($ch)) {

    print curl_error($ch);

} else {

    curl_close($ch);

    header( 'Content-type: ' . $response_headers['content-type']);

    print $response;

}

?>

kglad
Community Expert
Community Expert
August 15, 2010

that would go on the same server as your html and swf.  your swf would call that (local) php passing the appropriate parameters so the script could call your cross-domain php script.