cross server access in php
Can I get data from three different servers on my php application? Actually I have my data on three different servers and I want to generate a report with having data from all three servers. Can you please suggest me a code for this?
function dbcon(ipaddress,servername,serverpassword,databasename) { $con = mysql_connect(ipaddress,servername,serverpassword); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(databasename) or die ("Cant find DB"); }
Certainly that is possible. I assume (though you are not very clear in this) that you are talking about three database servers? Then all you have to do is:
Since opening a connection to a database server returns a handle you have something you can use to address a specific connection. The syntax required for opening the connection is clearly explained in the manual pages. I suggest you read them and take a look at the provided examples...
First:
Welcome to Stack Overflow! Please, don't use mysql_*
functions in new code . They are no longer maintained and the deprecation process has begun on it. See the red box ? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
In order to connect to three different databases, you'll need 3 connection objects, and query each separately. Make sure you have configured the receiving ends to correctly accept connections.
链接地址: http://www.djcxy.com/p/69526.html上一篇: 解析错误:语法错误,意外的T
下一篇: 在php中跨服务器访问