本地数据库,我试图从网络服务器连接到我的本地数据库,但我得到连接到远程Web服务器
Fatal error: Call to undefined function odbc_connect()
in -/-/-/70/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");
}
}
谢谢你的时间!
你正在'odbc_'与'mysql_'函数混合,*为什么?* – 2014-10-08 16:17:44
@ Fred-ii-,谢谢你的回复。我也要同步Sage 50 peachtree数据库与mysql_这就是为什么你看到mysql_函数。 – Keven 2014-10-08 16:24:37
这可能是相关信息http://sagecity.na.sage.com/support_communities/sage50_accounting_us/f/132/t/44819.aspx – RiggsFolly 2014-10-08 16:36:07