"Call to undefined function odbc_exec()" error connecting to Access database on Linux PHP server
I am getting the folowing error trying to run a test query on an Access Database "Fatal error: Call to undefined function odbc_exec() in /home/ratpackc/public_html/Preview/ADOdb/drivers/adodb-odbc.inc.php on line 536"
I downloaded (from http://adodb.sourc开发者_如何学Goeforge.net) and unzipped the entire contents of the adodb514.zip into a folder I named ADOdb. I am running the following test code:
<?PHP
include("ADOdb/adodb.inc.php");
$RecCount = 0;
$DBPath = realpath("TheData/TheData.mdb");
echo $DBPath . " <br />" . chr(13);
$DBConn =& ADONewConnection('access');
$DSN = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$DBPath;";
$DBConn->Connect($DSN);
$SqlStr = "SELECT TheDate FROM SomeTable ";
echo $SqlStr . " <br />" . chr(13);
$DBConn->debug = true;
if ($DBConn->Execute($SqlStr) === false) print ErrorMsg();
$RS = $DBConn->Execute($SqlStr);
if (!$RS)
echo $DBConn->ErrorMsg();
else
while (!$RS->EOF)
{
$RecCount++;
echo $RS->fields("TheDate")." <br />" . chr(13);
$RS->MoveNext();
}
$RS->Close();
$DBConn->Close();
echo "<hr />" . chr(13);
echo $RecCount." <br />" . chr(13);
?>
You can see the actual results of this code at http://www.rat-pack.com/Preview/DBTest.php
If it helps at all here is my phpinfo http://www.rat-pack.com/Preview/phpinfo.php
Create a sample file that contains:
<?php phpinfo();
If you don't see the odbc extension loaded you'll need to load it in your php.ini or recompile with odbc support.
Maybe because you don't have odbc installed or setup with php ?
精彩评论