发送数据到另一个数据库服务器

I've a website connected with database. When I fill the form the php script send the data to the database. The website and the database are on same server. To store the data in database I use:

    $con=mysql_connect('localhost',$id,$password);
    mysql_select_db($dabase,$con);
    $query=mysql_query($queryToRun);

This is how I send data to the database. Now I want to store the same form on a database stored on another server. Is it possible, if yes then how? Any kind of help is appreciated very much.

The remote database needs to be configured to allow remote connections. See this question.

Once that is set up, you just need to set the server IP/hostname in the mysql_connect() call instead of localhost.

Side note: The mysql_* API is deprecated, it is recommended to upgrade to MySQLi or PDO.

Instead of "localhost", enter in the ip address / host name of the server where database server is listening for requests. In order for this to work, that database server will have to allow requests from outside "localhost" aswell

You could just create two concurrent sets of connection variables and send the query to both of the database servers under question. For example, you could have:

  $dbConn1 = mysql_connect('address-of-the-first-database-server', 
  $userName1, $password1);
  mysql_select_db($dbName1, $dbConn1);

  $dbConn2 = mysql_connect('address-of-the-second-database-server', 
  $userName2, $password2);
  mysql_select_db($dbName2, $dbConn2);

  $execQuery = mysql_query($queryToRun, $dbConn1);
  $execQuery = mysql_query($queryToRun, $dbConn2);

PS: I would also recommend using more descriptive names for your variables, as this basically makes programming feel like writing structured English.