Copy link to clipboard
Copied
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;
?>
Copy link to clipboard
Copied
you almost certainly have a cross-domain security issue.
search for a php cross-domain proxy script.
Copy link to clipboard
Copied
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;
}
?>
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I was not successful. Are you able to show a working crossdomain script?
my swf & html > on SERVER A
php file to post data to the mysql > > on SERVER A
cross-domain file > on SERVER A
mysql 1 > > on SERVER A
mysql 2 > on SERVER B
php file to post data to the mysql > > on SERVER B
FLA
BUTTON 1
data to SERVER A
senderLoad.sendAndLoad("http://www.myweb1.com/x_proxy.php",receiveLoad);
BUTTON 2
data to SERVER A
senderLoad.sendAndLoad("http://www.myweb1.com/x_proxy.php?url=http://www.myweb2.com/bpx_db.php",receiveLoad);
Copy link to clipboard
Copied
no, i don't have one.
Copy link to clipboard
Copied
Thanks for the guidance. I hope I'll be able to complete my task.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Hello @Ron_Colmen ,
Do you remember where you found that PHP script? Do you happen to know what license that script has? @kglad, do you have any idea?
I really appreciate any help you can provide. 🙂
Copy link to clipboard
Copied