WAMP php ODBC连接“警告" [英] WAMP php ODBC Connection 'Warning'

查看:101
本文介绍了WAMP php ODBC连接“警告"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在php中使用ODBC时遇到了问题(WAMP Server 2.5,PHP 5.5.12).

I have a problem with ODBC in php (WAMP Server 2.5, PHP 5.5.12).

当我尝试运行时:

$conn = odbc_connect("odbc_dsn", "user", "pwd");

if ($conn) 
{
    echo "Connection established.";
} 
else
{
    exit("Connection could not be established.");
}

我收到警告:

Warning: odbc_connect(): in C:\wamp\www\Concepts\index.php on line 29

Connection could not be established.

如果我将"odbc_dsn"更改为"fdbasdf"之类的其他名称(不存在),则会得到:

If I change the "odbc_dsn" to something else (that doesn't exist) like "fdbasdf" then I get:

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] 
Der Datenquellenname wurde nicht gefunden, und es wurde kein Standardtreiber angegeben, 
SQL state IM002 in SQLConnect in C:\wamp\www\Concepts\index.php on line 

Connection could not be established.

(翻译)

The Data Source could not be  found, and no default driver is given.

这告诉我第一次执行能够找到数据库,但是没有打开它……为什么?

This tells me that the first execution was able to find the db, but did not open it... Why?

这是另一种配置吗?是否正在尝试执行客户端?我该怎么办?

Is this another config thing? Is it trying to execute Client-Side? What can I do?

推荐答案

您必须指定主机和连接协议:

You have to specify the Host and Connect protocol:

$connect_string =  "Driver={SQL Anywhere 12};".
                   "CommLinks=tcpip(Host=$db_host);".
                   "ServerName=$db_server_name;".
                   "DatabaseName=$db_name;";

// Connect to DB

$conn = odbc_connect( $connect_string, $db_user, $db_pass );

这篇关于WAMP php ODBC连接“警告"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆