简体   繁体   中英

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. I've tried odbc_connect and mssql_connect without any luck.

When using odbc_connect I get these errors:

[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. It's somewhat of an intense process if you're not familiar with 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

This answer assumes you are on a linux server, not Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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