我正试图从get服务器连接到本地数据库,但我得到了
Fatal error: Call to undefined function odbc_connect()
in -/-/-/7001238/web/s/sage2.php on line 15"任何关于如何解决问题的帮助。
这是我用来连接的代码。
$odbc['dsn'] = "Sage50";
$odbc['user'] = "Peach";
$odbc['pass'] = "XXXX";
$mysql['host'] = "localhost";
$mysql['user'] = "root";
$mysql['pass'] = "";
$mysql['dbname'] = "sagetest";
$mysql['idfield'] = "id";
$debug=true;
// Step 1: Connect to the source ODBC and target mysql database
if ($debug) echo "Connect to " . $odbc['dsn'] . ' as ' . $odbc['user'] . "\n";
$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']);
if (!$conn) {
die("Error connecting to the ODBC database: " . odbc_errormsg());
}
$myconn = mysql_connect($mysql['host'], $mysql['user'], $mysql['pass']);
if (!$myconn)
die("Error connecting to the MySQL database: " . $mysql_error());
if (!mysql_select_db($mysql['dbname'], $myconn)) die("Error selecting the database: " . mysql_error());
// Step 1.5: loop through each table with steps 2-7
$allTables = odbc_tables($conn);
$tablesArray = array();
while (odbc_fetch_row($allTables)) {
if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {
$tablesArray[] = odbc_result($allTables, "TABLE_NAME");
}
}谢谢您抽时间见我!
发布于 2014-10-08 16:52:02
首先:发生此错误是因为您没有安装ODBC扩展。
也检查一下http://php.net/manual/en/odbc.installation.php。
在debian发行版中,您可以使用apt-get install php5-odbc来解决这个问题,但是您也可以通过您的主机提供商检查这个问题。
当您看到一个Call to undefined function时,您必须始终检查php.net,以确定函数的名称,否则就没有加载扩展。
PS 1:我想你是在比较/传输两个数据库之间的数据,对吗?
确保您的服务器能够到达ODBC地址。dev服务器不是开发机器,因此localhost不是真正的localhost ;)
https://stackoverflow.com/questions/26261586
复制相似问题