doujuegai8830
2014-10-08 16:13
浏览 128
已采纳

从远程Web服务器连接到本地数据库

I am trying to connect to my local Database from the webserver but i get

Fatal error: Call to undefined function odbc_connect() 
             in -/-/-/7001238/web/s/sage2.php on line 15"

Any help on how to fix issue.

Here is the code i used to connect.

 $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'] . "
";
 $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");
   }
}

Thank you for your time!

图片转代码服务由CSDN问答提供 功能建议

我正在尝试从网络服务器连接到我的本地数据库,但我得到了</ p> < pre> 致命错误:在第15行“/ n </ code> </ pre> \中调用 - / - / - / 7001238 / web / s / sage2.php中的未定义函数odbc_connect() n

有关如何解决问题的任何帮助。</ p>

以下是我用来连接的代码。</ p>

  $ 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; 
 //步骤1:连接到源ODBC和目标mysql数据库
 if($ debug)echo“Connect to”。$ odbc ['dsn']。'  as'。$ odbc ['user']。“
”; 
 $ conn = odbc_connect($ odbc ['dsn'],$ odbc ['user'],$ odbc ['pass']); 
  if(!$ conn){
 die(“错误连接到ODBC数据库:”。odbc_errormsg()); 
} 
 $ myconn = mysql_connect($ mysql ['host'],$ mysql ['user'  ],$ mysql ['pass']); 
 if(!$ myc  onn)
 die(“连接MySQL数据库时出错:”。  $ mysql_error()); 
 if(!mysql_select_db($ mysql ['dbname'],$ myconn))die(“选择数据库时出错:”。mysql_error()); 
 //步骤1.5:遍历每个 具有步骤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”); 
} 
} 
 </ code> </ pre> 
 
 

感谢您的支持 时间!</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题