PHP ODBC 连接无法连接到 Sybase 数据库

发布于 2024-08-08 22:01:40 字数 1306 浏览 8 评论 0原文

我使用 PHP 设置了一个网站,通过 ODBC 连接与 Sybase 数据库(已用于内部应用程序)进行通信,以便现场用户可以访问内部数据库。这是在 2003 NT 服务器上,一切正常。

然后,我在 XP Pro 计算机上设置了一个类似的网站(这次是我自己),虽然该网站可以访问,并且 PHP 编程可以工作,但 PHP 页面无法访问数据库。我没有收到任何错误,我检查了两个站点(工作和非工作)之间的 phpinfo 并且没有提出任何想法。

确信通过 ODBC 连接到数据库不起作用,XP Pro 上的配置是否应该与 2003 NT 机器上的配置不同?两台计算机上的 ODBC 设置方式相同。

<?php
$Page_Name = "apptlist1.php";
import_request_variables('gpc');

$db_host = "wintermlocal";
$db_server_name = "winpest";
$db_name = "windata.db";
$db_file = "c:\data\windata.db";
$db_conn_name = "php_script";
$db_user = "dba";
$db_pass = "sql";
//================================================================
$connect_string = "Driver={Adaptive Server Anywhere 7.0};"
    ."CommLinks=tcpip(Host=$db_host);"
    ."ServerName=$db_server_name;"
    ."DatabaseName=$db_name;"
    ."DatabaseFile=$db_file;"
    ."ConnectionName=$db_conn_name;"
    ."uid=$db_user;pwd=$db_pass";
//================================================================

$connect = odbc_connect($connect_string,'','');
?>

警告:odbc_connect() [function.odbc-connect]:

SQL 错误:[Microsoft][ODBC 驱动程序管理器]

未找到数据源名称且未指定默认驱动程序

第 22 行 C:\Inetpub\wwwroot\allpro\apptlist1.php 中 SQLConnect 中的 SQL 状态 IM002

I set up a web site using PHP to talk to a Sybase db (already in use for a in-house application) via an ODBC connection, so users in the field could access the in-house db. This was on a 2003 NT server, and everything worked fine.

Then I set up a similar site on an XP Pro machine (this time, by myself), and while the web site is accessible, and the PHP programming works, the PHP pages cannot access the db. I get no errors, I've checked phpinfo between the two sites (working and non-working) and have come up with no ideas.

Convinced the connect to database via ODBC not working, should the configuration on an XP Pro be different than from a 2003 NT machine? ODBC is set up the same way on both machines.

<?php
$Page_Name = "apptlist1.php";
import_request_variables('gpc');

$db_host = "wintermlocal";
$db_server_name = "winpest";
$db_name = "windata.db";
$db_file = "c:\data\windata.db";
$db_conn_name = "php_script";
$db_user = "dba";
$db_pass = "sql";
//================================================================
$connect_string = "Driver={Adaptive Server Anywhere 7.0};"
    ."CommLinks=tcpip(Host=$db_host);"
    ."ServerName=$db_server_name;"
    ."DatabaseName=$db_name;"
    ."DatabaseFile=$db_file;"
    ."ConnectionName=$db_conn_name;"
    ."uid=$db_user;pwd=$db_pass";
//================================================================

$connect = odbc_connect($connect_string,'','');
?>

Warning: odbc_connect() [function.odbc-connect]:

SQL error: [Microsoft][ODBC Driver Manager]

Data source name not found and no default driver specified

SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\allpro\apptlist1.php on line 22

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖 2024-08-15 22:01:40

你说 $doresult 是 0,但实际上问题是 $connect 是 0,对吗?

这可能是对 .db 文件的保护。

数据库是否已由某些 ASA 服务引擎(将定义 server=winpest、dbname=windata)运行,或者您是否希望 PHP 脚本在需要时启动引擎?
在这种情况下,我经常遇到数据库引擎 (dbeng7) 不在系统路径中的问题,这会阻止 ODBC 驱动程序根据请求启动引擎数据库。

You're saying that $doresult is 0, but in fact the problem is that $connect is 0, correct?

It could be the protections on the .db file.

Is the database already run by some ASA service engine (which would define server=winpest, dbname=windata) or do you expect the PHP script to start the engine if needed?
In that case, I often had problems around the database engine (dbeng7) not being in the system path, which prevents the ODBC driver from starting the engine database on request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文