【发布时间】:2014-03-27 05:29:10
【问题描述】:
我尝试在单个 php 文件中连接两个数据库,并尝试通过连接两个数据库的表来检索数据。这是我的代码
require_once "connect.php";
require_once "connect_college.php";
$sql = "select * from college_db.students join mini-project.exam on students.adno=exam.adno and students.receipt=exam.receipt ";
if (!mysql_query($sql))
{
die('Error');
}
else
{
header("Location: generate.php");
exit();
}
Mysql 查询没有运行。 College_db 和 mini-project 是两个数据库。
【问题讨论】:
-
您无法连接来自 2 个不同数据库连接或服务器的数据,您必须在数据库服务器 A 上运行选择查询,将结果放入数组或 w/e 然后在数据库服务器 B 上运行第二个查询.
-
你在
mysql_error()有什么?