本地數據庫,我試圖從網絡服務器連接到我的本地數據庫,但我得到連接到遠程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