[英]PHP connectivity with MS SQL using odbc_connect
I am working on a PHP project where I have to create an API to fetch data from client's MS SQL server. 我正在一个PHP项目中,我必须创建一个API才能从客户端的MS SQL服务器获取数据。 I am doing it as- 我正在这样做-
$connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server_ip;Database=$databse;", $username, $password);
Its working on my localhost(might be because I have SQL Server install on my system, but not sure). 它可以在我的本地主机上运行(可能是因为我在系统上安装了SQL Server,但不确定)。 But does not work on hosting server. 但不适用于托管服务器。 It gives error- 它给出了错误-
[unixODBC][Driver Manager]Can't open lib 'SQL Server Native Client 10.0' : file not found
I have even tried - 我什至试过-
$serverName = $server_ip;
$connectionInfo = array( "Database"=>$database, "UID"=>$username, "PWD"=>$password);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$conn does not return anything.
Is there any other alternative? 还有其他选择吗?
I have even got odbc driver install. 我什至安装了odbc驱动程序。
There is an alternative (extension) called php-sybase. 还有一个替代方法(扩展名),称为php-sybase。 I am using it successfully to connect to various (versions) MSSQL databases with different php versions, to mention just: 5.6 and 7.0. 我成功地使用它来连接到具有不同php版本的各种(版本)MSSQL数据库,仅提及5.6和7.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.