尝试将托管的Web应用程序连接到本地数据库?

I am trying to connect hosted webs application to Local database. First I was getting Fatal error: Call to undefined function odbc_connect() error but after add the "odbc" extension i started getting

Error connecting to the ODBC database: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

I used the following code in php script to connect to the Local database using ODBC

$odbc['dsn'] = "SageLine50v19";
$odbc['user'] = "Peac";
$odbc['pass'] = "XXXX";
$mysql['host'] = "localhost";
$mysql['user'] = "root";
$mysql['pass'] = "";
$mysql['dbname'] = "sagetest";
$mysql['idfield'] = "id";


// Step 1: Connect to the source ODBC 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());
}

// loop through each table 
$allTables = odbc_tables($conn);
$tablesArray = array();
while (odbc_fetch_row($allTables)) {
 if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {
    $tablesArray[] = odbc_result($allTables, "TABLE_NAME");
 }
}
 //print_r($tablesArray);      // to list all tables

My ODBC.ini looks like below

[ODBC 32 bit Data Sources]
t=SQL Server Native Client 10.0 (32 bit)
SageLine50v19=Pervasive ODBC Client Interface (32 bit)

[t]
Driver32=C:\Windows\system32\sqlncli10.dll
[SageLine50v19]
Driver32=C:\Program Files (x86)\Pervasive Software\PSQL\bin\w3odbcci.dll

Error connecting to the ODBC database: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

Problem:

This is your data source name:

[ODBC 32 bit Data Sources]

But in your php you put

$odbc['dsn'] = "SageLine50v19";

Solution:

Decide wich one you change:

odbc.ini

[SageLine50v19]

or php

$odbc['dsn'] = "ODBC 32 bit Data Sources";

Exactly what platform is this on?

Given unixODBC I would expect Unix/Linux. But the drivers being .dll's indicate Windows. Which one is it?

If the driver manager tries to load a lib and fails, it will give the "Data source name not found, and no default driver specified" (thats what the spec insists it does), if you are trying to use windows drivers on Unix, then I would expect it to fail to load.