“调用未定义的函数 odbc_exec()”连接到 Linux PHP 服务器上的 Access 数据库时出错
我尝试在 Access 数据库上运行测试查询时收到以下错误 “致命错误:在第 536 行调用 /home/ratpackc/public_html/Preview/ADOdb/drivers/adodb-odbc.inc.php 中未定义的函数 odbc_exec()”
我下载了(来自 http://adodb.sourceforge.net) 并将 adodb514.zip 的全部内容解压缩到文件夹中名为 ADOdb。 我正在运行以下测试代码:
<?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);
?>
如果有帮助,这里是我的 phpinfo http://www.rat-pack.com/Preview/phpinfo.php
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.sourceforge.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个示例文件,其中包含:
如果您没有看到加载的 odbc 扩展,则需要将其加载到 php.ini 中或使用 odbc 支持重新编译。
Create a sample file that contains:
If you don't see the odbc extension loaded you'll need to load it in your php.ini or recompile with odbc support.
也许是因为您没有安装 odbc 或使用 php 设置?
Maybe because you don't have odbc installed or setup with php ?