简体   繁体   English

使用PHP连接到SQL Server

[英]Connect to SQL Server with PHP

I am trying to connect to a remote SQL Server Windows 2008R2 and a file server Windows 2008. I am wondering what the best way is to handle this. 我正在尝试连接到远程SQL Server Windows 2008R2和文件服务器Windows2008。我想知道最好的方法是处理此问题。 I've tried odbc_connect and mssql_connect without any luck. 我已经尝试了odbc_connect和mssql_connect,但没有任何运气。

When using odbc_connect I get these errors: 使用odbc_connect时出现以下错误:

[unixODBC][Driver Manager]Data source name not found, and no default driver specified

[16-Jan-2014 16:02:12 UTC] PHP Warning:  odbc_connect() [<a href='function.odbc-
connect'>function.odbc-connect</a>]: SQL error: [unixODBC][Driver Manager]Data source
name not found, and no default driver specified, SQL state IM002 in SQLConnect in
/mnt/stor12-wc1-dfw1/657080/843636/www.ia764.org/web/content/cms/wp-content/themes
/iatse/functions/syntonics.php on line 27

This is not my area of expertise so layman's terms are welcomed. 这不是我的专业领域,因此欢迎外行的用语。

Any help/guidance would be greatly appreciated! 任何帮助/指导将不胜感激!

I had this problem, too. 我也有这个问题。 What you need to do is install FreeTDS so you can use the ODBC drivers. 您需要做的是安装FreeTDS,以便可以使用ODBC驱动程序。 It's somewhat of an intense process if you're not familiar with linux. 如果您不熟悉linux,那么这个过程有些紧张。 However, I've documented all the steps in the answers here Connect PHP to MSSQL via PDO ODBC and here Can't Install FreeTDS via Yum Package Manager 但是,我已经记录了答案中的所有步骤,在此处通过PDO ODBC将PHP连接到MSSQL ,在此处无法通过Yum Package Manager安装FreeTDS。

This answer assumes you are on a linux server, not Windows. 此答案假定您使用的是Linux服务器,而不是Windows。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM